public ActionResult Edit(PPKViewModel model) { try { PPK program = new PPK() { Id = model.Id, Name = model.Name, OldId = model.OldId.Value }; var response = _ppkLogic.Edit(program); if (response.IsError == true) { foreach (var item in response.ErrorCodes) { ModelState.AddModelError(string.Empty, item); } PrepareSelectList(model.Id); return(View(model)); } return(RedirectToAction("Index")); } catch { return(View()); } }
public PPK Edit(PPK entity) { var oldData = _db.PPKs.SingleOrDefault(c => c.Id == entity.OldId); _db.PPKs.Remove(oldData); _db.PPKs.Add(entity); _db.SaveChanges(); return(entity); }
public ResponseMessage Edit(PPK entity) { ResponseMessage response = new ResponseMessage(); if (_repository.IsPPKExist(entity.Name, entity.Id)) { response.IsError = true; response.ErrorCodes.Add("PPK Already Exist"); return(response); } _repository.Edit(entity); return(response); }
public void Create(PPK entity) { _db.PPKs.Add(entity); _db.SaveChanges(); }