public IActionResult Uredi(int id) { MyContext db = new MyContext(); Let l = db.Let.Where(x => x.LetID == id).Include(x => x.Grad).Include(x => x.Klasa).FirstOrDefault(); LetUrediVM model = new LetUrediVM { id = id, klase = db.Klasa.Select(x => new SelectListItem { Value = x.KlasaID.ToString(), Text = x.Naziv }).ToList(), gradovi = db.Grad.Select(x => new SelectListItem { Value = x.GradID.ToString(), Text = x.Naziv }).ToList(), VrijemePolaska = l.VrijemePolaska, Cijena = l.Cijena }; db.SaveChanges(); db.Dispose(); return(View(model)); }
public IActionResult UrediSnimi(LetUrediVM model) { MyContext db = new MyContext(); Let l = db.Let.Where(x => x.LetID == model.id).Include(x => x.Grad).Include(x => x.Klasa).FirstOrDefault(); l.LetID = model.id; l.KlasaID = model.klasaid; l.GradID = model.gradid; List <SelectListItem> klase = db.Klasa.Select(x => new SelectListItem { Value = x.KlasaID.ToString(), Text = x.Naziv }).ToList(); List <SelectListItem> gradovi = db.Grad.Select(x => new SelectListItem { Value = x.GradID.ToString(), Text = x.Naziv }).ToList(); l.VrijemePolaska = model.VrijemePolaska; l.Cijena = model.Cijena; db.SaveChanges(); db.Dispose(); return(RedirectToAction("Prikazi")); }