public ActionResult Edit(int id) { var temp = _context.NewBuildings.FirstOrDefault(t => t.Id == id); NewBuildingEditViewModel model = new NewBuildingEditViewModel() { Parking = temp.Parking, Picture = temp.Picture, StreetName = temp.StreetName, Warming = temp.Warming, City = temp.City, ConstructionStatus = temp.ConstructionStatus, DateOfConstructed = temp.DateOfConstructed, Floors = temp.Floors }; return(View(model)); }
public ActionResult Edit(NewBuildingEditViewModel model) { if (ModelState.IsValid) { var temp = _context.NewBuildings.FirstOrDefault(t => t.Id == model.Id); temp.Parking = model.Parking; temp.Picture = model.Picture; temp.StreetName = model.StreetName; temp.Warming = model.Warming; temp.City = model.City; temp.ConstructionStatus = model.ConstructionStatus; temp.DateOfConstructed = model.DateOfConstructed; temp.Floors = model.Floors; _context.SaveChanges(); return(RedirectToAction("Index", "NewBuilding")); } return(View(model)); }