public UpdateEntity ( |
||
item | ||
return | void |
public IActionResult Edit(HousingEditModel housing, int editId) { if (ModelState.IsValid) { var dbItem = _context.Housing.GetFullById(editId); housing.UpdateEntity(dbItem); _context.Update(dbItem); _context.SaveChanges(); TempData["CrmSuccessMessage"] = "Запись была успешно сохранена"; return RedirectToAction("Index"); } var errors = ModelState.Values.Where(x => x.Errors.Any()).ToList(); return View("Save", housing); }
public IActionResult Create(HousingEditModel housing) { if (ModelState.IsValid) { var newHousingItem = new Housing() { Phones = new List<HousingPhone>() }; housing.UpdateEntity(newHousingItem); _context.Housing.Add(newHousingItem); _context.SaveChanges(); return RedirectToAction("Index"); } return View("Save", housing); }