public void Insert(SettingVIewModel model) { var entity = new Setting() { Id = model.Id, Type = model.Type, Value = model.Value }; Repository.Insert(entity); UnitOfWork.Save(); }
public ActionResult Edit(SettingVIewModel model) { if (ModelState.IsValid) { try { _settingService.Update(model); return(RedirectToAction("Index")); } catch (Exception) { } } return(View(model)); }
public void Update(SettingVIewModel model) { if (string.IsNullOrEmpty(model.Id)) { throw new Exception("Setting key is null"); } var entity = Repository.Get(model.Id); if (entity == null) { throw new Exception("Setting key is not found"); } //entity.Id = model.Id; entity.Type = model.Type; entity.Value = model.Value; Repository.Update(entity); UnitOfWork.Save(); }
public ActionResult Edit(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index")); } var entity = _settingService.FindById(id); if (entity == null) { return(RedirectToAction("Index")); } var model = new SettingVIewModel() { Id = entity.Id, Value = entity.Value, Type = entity.Type }; return(View(model)); }