public ActionResult Edit(int Id) { var entity = _settingService.GetById(Id); var model = new SettingModel(); if (entity != null) { Mapper.CreateMap<Setting, SettingModel>(); Mapper.Map(entity, model); } return PartialView("_CreateOrUpdate", model); }
//[ValidateAntiForgeryToken] public ActionResult CreateOrUpdate(SettingModel model) { var entity = model.Id > 0 ? _settingService.GetById(model.Id) : new Setting(); Mapper.CreateMap<SettingModel, Setting>(); Mapper.Map(model, entity); entity.LastUpdated = DateTime.Now; if (entity.Id == 0) _settingService.Insert(entity); else _settingService.Update(entity); return Content("success"); }
public ActionResult Create() { var model = new SettingModel(); model.CreatedDate = DateTime.Now; return PartialView("_CreateOrUpdate", model); }