public ActionResult EditArea(AreaModel areaDetails) { if (ModelState.IsValid) { var currentUser = Request.GetOwinContext().Authentication.User.Identity.GetUserId(); _instructorRepo.UpdateArea(currentUser, areaDetails); return View("Area"); } return View(); }
public void UpdateArea(string userId, AreaModel area) { var areaDetails = DataContext.Areas.FirstOrDefault(s => s.AreaId == area.AreaId) ?? new Area(); areaDetails.Name = area.Name; areaDetails.Description = area.Description; if (areaDetails.AreaId == 0) { areaDetails.CreatedDate = DateTime.Now; areaDetails.CreatedBy = userId; DataContext.Areas.Add(areaDetails); } SaveInDatabase(); }