public ActionResult Edit(OPDBudgetViewModel model) { try { OPDBudget activity = new OPDBudget() { Id = model.Id, Budget = model.Budget, OPDId = model.OPDId, Year = model.Year }; var response = _opdBudgetLogic.Edit(activity); if (response.IsError == true) { foreach (var item in response.ErrorCodes) { ModelState.AddModelError(string.Empty, item); } return(View(model)); } return(RedirectToAction("View", "OPD", new { id = model.OPDId })); } catch { return(View()); } }
public ActionResult Create(OPDBudgetViewModel model) { try { OPDBudget opdBudget = new OPDBudget() { Budget = model.Budget, Year = model.Year, OPDId = model.OPDId }; var response = _opdBudgetLogic.Create(opdBudget); if (response.IsError == true) { foreach (var item in response.ErrorCodes) { ModelState.AddModelError(string.Empty, item); } ViewData["OPDId"] = model.OPDId; return(View(model)); } return(RedirectToAction("View", "OPD", new { id = model.OPDId })); } catch { return(View()); } }
public OPDBudget Edit(OPDBudget entity) { var opdBudget = _db.OPDBudgets.Find(entity.Id); _db.Entry(opdBudget).CurrentValues.SetValues(entity); _db.SaveChanges(); return(opdBudget); }
public ResponseMessage Create(OPDBudget entity) { ResponseMessage response = new ResponseMessage(); if (_repository.IsOPDBudgetExist(entity.Year, entity.OPDId)) { response.IsError = true; response.ErrorCodes.Add("Budget for this year already exist"); return(response); } _repository.Create(entity); return(response); }
public void Create(OPDBudget entity) { _db.OPDBudgets.Add(entity); _db.SaveChanges(); }