Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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());
            }
        }
Ejemplo n.º 3
0
        public OPDBudget Edit(OPDBudget entity)
        {
            var opdBudget = _db.OPDBudgets.Find(entity.Id);

            _db.Entry(opdBudget).CurrentValues.SetValues(entity);
            _db.SaveChanges();
            return(opdBudget);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public void Create(OPDBudget entity)
 {
     _db.OPDBudgets.Add(entity);
     _db.SaveChanges();
 }