Sygmond
Sygmond
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
but with a group or a list like you said, is way simpler than the current implementation
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
yes, is in the DB, but is loaded in the memory (UI) and if a new item is added in any alternative group, is tracked and saved separately.
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
assign a groupId to the ones you want to be alternatives and done
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
what I proposed is grouping, because this is esentially groups
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
and each item would have an id that points to that list?
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
you have to check each item where A is an alternative and add D and to D add the item that you just checked
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
the problem is if I add D to the list of A, that D needs to be added to the rest of the items.Alternatives
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
like in my example?
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
each item has its own tab with a grid where all alternatives for that item is listed
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
If I add D as alternative to A, D will be alternative to all. Is not important in the UI why. I just need to list/print the alternatives of each.
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
No, I just need to know that A is an alternative to C
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
Yes. Each item needs to have complete list of alternatives, so every new alternative item added, the synchronization needs to be done again and add in each item the new alternative
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
yes
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
This is what it was designed by someone else. I proposed to my PM a simpler solution. Initially I was ignored and now the whole thing got to complicated. Looking forward to see what other people have in mind, without clouding them with my solution.
26 replies
CC#
Created by Sygmond on 7/11/2024 in #help
How to implement alternative items. A is alt. to B and C => B alt. to A and C, etc.
currently is implemented like this
using System;
using System.Collections.Generic;

public class Program
{
public static void Main()
{
// we have 3 items: A, B and C
var a = new Item {Name = "A"};
var b = new Item {Name = "B"};
var c = new Item {Name = "C"};

var items = new List<Item>()
{
a,
b,
c,
};

// add B as an alternative to A
a.Alternatives.Add(b);

// that means A is an alternative to B
b.Alternatives.Add(a);

// add C as an alternative to B
b.Alternatives.Add(c);

// that means B is an alternative to C
c.Alternatives.Add(b);

// and now the complication: it means that C is an alternative to A too, because A is alternative to B
a.Alternatives.Add(c);

// and it means A is an alternative to C too
c.Alternatives.Add(a);

// let's print the alternatives
foreach(var item in items)
{
Console.Write($"Item {item.Name} has the alternatives: ");

foreach(var alternative in item.Alternatives)
{
Console.Write($"{alternative.Name} ");
}

Console.WriteLine();
}

// Result:
// Item A has the alternatives: B C
// Item B has the alternatives: A C
// Item C has the alternatives: B A

// then... trying to add/remove numerous alternatives...
// would make all thing way to complicated to sync all item.Alternatives in each
}
}

public class Item
{
public string Name {get; set;}
public List<Item> Alternatives {get; set;} = new();
}
using System;
using System.Collections.Generic;

public class Program
{
public static void Main()
{
// we have 3 items: A, B and C
var a = new Item {Name = "A"};
var b = new Item {Name = "B"};
var c = new Item {Name = "C"};

var items = new List<Item>()
{
a,
b,
c,
};

// add B as an alternative to A
a.Alternatives.Add(b);

// that means A is an alternative to B
b.Alternatives.Add(a);

// add C as an alternative to B
b.Alternatives.Add(c);

// that means B is an alternative to C
c.Alternatives.Add(b);

// and now the complication: it means that C is an alternative to A too, because A is alternative to B
a.Alternatives.Add(c);

// and it means A is an alternative to C too
c.Alternatives.Add(a);

// let's print the alternatives
foreach(var item in items)
{
Console.Write($"Item {item.Name} has the alternatives: ");

foreach(var alternative in item.Alternatives)
{
Console.Write($"{alternative.Name} ");
}

Console.WriteLine();
}

// Result:
// Item A has the alternatives: B C
// Item B has the alternatives: A C
// Item C has the alternatives: B A

// then... trying to add/remove numerous alternatives...
// would make all thing way to complicated to sync all item.Alternatives in each
}
}

public class Item
{
public string Name {get; set;}
public List<Item> Alternatives {get; set;} = new();
}
https://dotnetfiddle.net/rJQSRv
26 replies
CC#
Created by Sygmond on 4/17/2024 in #help
Is using a blazor component from a service a good idea?
Short version: Is better to use components via a service compared with the standard practice of placing the component where is needed and using it directly? The service would have to be injected in the component and in the page where the component needs to be used. The service would hold the business logic, the component will act as UI only and any functions needed in the component would be executed from the service.
2 replies
CC#
Created by Sygmond on 3/29/2024 in #help
✅ Missing reference for one entity but not for another
and the namespace of some classes ware containing the word Item and make conflict with the entity Item
18 replies
CC#
Created by Sygmond on 3/29/2024 in #help
✅ Missing reference for one entity but not for another
@TeBeCo yep, thank you! That was. Some folders ware in the singular form, i.e. Item instead of Items and the entity was Item too...
18 replies
CC#
Created by Sygmond on 3/29/2024 in #help
✅ Missing reference for one entity but not for another
maybe I spot something. Sharing the code is kind of impossible because is a really big project
18 replies