public ActionResult Create() { temp = new ProdukcjaViewModel(); temp.idDzialu = new SelectList(db.dzial, "iddzial", "nazwa"); return View(temp); }
public ActionResult Create(ProdukcjaViewModel prod) { if (ModelState.IsValid) { produkcja produkcja = new produkcja(); produkcja.dzial = db.dzial.Find(prod.b.dzialId); produkcja = prod.b; produkcja.data = DateTime.Now; int i = 0; foreach (var item in temp.a) { lista_towarow lista = new lista_towarow(); towary jakis = db.towary.Find(item.idtowary); lista.towary = jakis; lista.ilosc = temp.listaIlosc[i]; produkcja.lista_towarow.Add(lista); i++; } db.produkcja.Add(produkcja); db.SaveChanges(); //produkcja.idDzialu = new SelectList(db.dzial, "iddzial", "nazwa", temp.b.dzialId); return RedirectToAction("Index"); } temp.idDzialu = new SelectList(db.dzial, "iddzial", "nazwa", temp.b.dzialId); return View(temp); }
public ActionResult Lista(ProdukcjaViewModel p) { p.temporary = new towary(); try { p.temporary = (from t in db.towary where t.kod_kreskowy == p.nazwa select t).First(); } catch { p.temporary = (from t in db.towary where t.nazwa == p.nazwa select t).FirstOrDefault(); } temp.idDzialu = new SelectList(db.dzial, "iddzial", "nazwa",p.b.dzialId); temp.a.Add(p.temporary); temp.listaIlosc.Add(p.ilosc); temp.nazwa = string.Empty; return View("Create",temp); }