List <ProductLocal> LoadGridView(List <ProductLocal> pros, int index) { pros3.Clear(); for (int i = 0; i < pros.Count(); i++) { if (pros[i].IdCat == index + 1) { ProductLocal pro = new ProductLocal(); pro.IdProduct = pros[i].IdProduct; pro.IdCat = pros[i].IdCat; pro.NameProduct = pros[i].NameProduct; pro.ImgProduct = pros[i].ImgProduct; pro.DescriptionProduct = pros[i].DescriptionProduct; pros3.Add(pro); } } return(pros3); }
private static List <ProductLocal> FromDBToLocal(List <Product> pros) { List <ProductLocal> proslocal = new List <ProductLocal>(); int i = 0; while (i < pros.Count) { ProductLocal p = new ProductLocal(); p.IdProduct = pros[i].IdProduct; p.NameProduct = pros[i].NameProduct; p.DescriptionProduct = (pros[i].IdCat == 1) ? "Cà phê": (pros[i].IdCat == 2) ? "Đá xay" : (pros[i].IdCat == 3) ? "Trà trái cây" : (pros[i].IdCat == 4) ? "Sinh tố" : (pros[i].IdCat == 5) ? "Macchiato" : (pros[i].IdCat == 6) ? "Khác" : (pros[i].IdCat == 7) ? "Topping" : "Snack"; p.ImgProduct = pros[i].imgProduct; p.IdCat = pros[i].IdCat; proslocal.Add(p); i++; } return(proslocal); }