public List <CurentMenu> CreateCurentMenu(List <string> val) { List <CurentMenu> men = new List <CurentMenu>(); for (int i = 0; i < val.Count; i++) { CurentMenu mn = new CurentMenu(); mn.Denumire = val.ElementAt(i); if (Menu != null) { if (Menu.Count != 0) { if (Menu.Count >= i) { for (int j = 0; j < Menu.Count; j++) { if (mn.Denumire == Menu.ElementAt(j).Denumire) { mn.Cantitate = Menu.ElementAt(j).Cantitate; } } } } } men.Add(mn); } return(men); }
public void initializare2() { EditMenu = true; var res = contex.GetAllCategorii(); var result = res.Select(x => new GetAllCategorii_Result { denumire = x.denumire, id_categorie = x.id_categorie } ).ToList(); List <string> l = new List <string>(); for (int i = 0; i < result.Count; i++) { var aux = result.ElementAt(i).denumire; l.Add(aux); } Categorii = l; var res1 = contex.SPGetPreparateByMenu(Denumire); var resul1 = res1.Select(x1 => new SPGetPreparateByMenu_Result { denumire = x1.denumire, cantitate = x1.cantitate, cantitate_restaurant = x1.cantitate_restaurant, pret = x1.pret }).ToList(); List <CurentMenu> men = new List <CurentMenu>(); List <string> listPrep = new List <string>(); for (int i = 0; i < resul1.Count; i++) { CurentMenu mn = new CurentMenu(); mn.Denumire = resul1.ElementAt(i).denumire; mn.Cantitate = int.Parse(resul1.ElementAt(i).cantitate.ToString()); listPrep.Add(resul1.ElementAt(i).denumire); men.Add(mn); } Menu = new List <CurentMenu>(); Menu = men; OnPropertyChanged("menu"); PreparateCurente = listPrep; var res2 = contex.SPGetPreparate(); var resul2 = res2.Select(x1 => new SPGetPreparate_Result { cantintate_portie = x1.cantintate_portie, cantitate_restaurant = x1.cantitate_restaurant, denumire = x1.denumire, id_categorie = x1.id_categorie, id_preparat = x1.id_preparat, pret = x1.pret }).ToList(); List <string> l1 = new List <string>(); for (int i = 0; i < resul2.Count; i++) { var aux = resul2.ElementAt(i).denumire; l1.Add(aux); } for (int i = 0; i < l1.Count; i++) { for (int j = 0; j < resul1.Count; j++) { if (l1.ElementAt(i) == resul1.ElementAt(j).denumire) { l1.RemoveAt(i); } } } Preparate = l1; }