I'm having a question about how to model the Produto
table of a small e-commerce I'm doing. I've been seeing some e-commerces and I came across the following situation: mm same product can have different colors and sizes, so when the customer chooses the product in a different color the system pulls the same product but with different color and size available, being so apparently the product is registered more than 1x with the same name, but different colors and sizes, even because the product code is always different, that is, the same product can have several different codes, sizes, colors but the name is always the same, and I believe this is the cat's leap, correct me if I'm wrong.
Following this logic, I'm trying to model my Produto
class in this way, but I came across a deadlock in inventory because the product can have the same name, different codes, different colors, different sizes, but manage inventory from the size becomes a bit complicated, because the same product can have different sizes in the stock and at the time of giving the output of the stock I need to rely on this situation. So I wanted to know the best way to do this?
Product table.
[Serializable]
public class Produto{
public virtual long id { get; set; }
public virtual String descricao { get; set; }
public virtual String descDetalhada { get; set; }
public virtual Subcategoria subcategoria { get; set; }
public virtual IList<Cor> cores { get; set; }
public virtual IList<Tamanho> tamanhos { get; set; }
public virtual int qtdEstoque { get; set; }
public virtual decimal precoAntigo { get; set; }
public virtual decimal precoReal { get; set; }
public virtual int status { get; set; }
public Produto(){
cores = new List<Cor>();
tamanhos = new List<Tamanho>();
}
public override string ToString(){
return descricao;
}
}