public ActionResult EditReferences(ApplicationReferenceViewModel model) { if (ModelState.IsValid) { refService.Edit(ReferencesMapper.ToEntity(model)); return(RedirectToAction("Index", "References")); } ViewBag.ListReferences = refService.GetAll.ToList(); return(View(model)); }
public ActionResult EditReferences(int Id = 0) { ApplicationReferenceViewModel model = new ApplicationReferenceViewModel(); if (Id != 0) { var entity = refService.GetById(Id); model = ReferencesMapper.ToViewModel(entity); } ViewBag.ListReferences = refService.GetAll .Where(x => x.IsParent && !x.IsDelete); return(View(model)); }
public static ApplicationReferences ToEntity(ApplicationReferenceViewModel model) { return(new ApplicationReferences { Id = model.Id, Alias = model.Alias, Key = model.Key, ParentId = model.ParentId, Name = model.Name, Value = model.Value, IsActive = model.IsActive, IsDelete = model.IsDelete, IsParent = model.IsParent }); }