Ejemplo n.º 1
0
        public JsonResult Edit(CostPlanViewModel model, int marketingYearId)
        {
            string message = String.Empty;

            try
            {
                _costPlanService.UpdateCostPlan(model, marketingYearId);
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(Json(new { message }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public void UpdateCostPlan(CostPlanViewModel model, int marketingYearId)
        {
            if (model.Type <= 0)
            {
                throw new Exception("Nie można edytować planu kosztów koła łowieckiego");
            }

            var dto = new CostPlanDto
            {
                Type            = model.Type,
                Cost            = model.Cost,
                MarketingYearId = marketingYearId
            };

            _costPlanDao.Update(dto);
        }
Ejemplo n.º 3
0
        public void AddCostPlan(CostPlanViewModel model, int marketingYearId)
        {
            if (model.Type == 0)
            {
                throw new Exception("Nie można dodać planu kosztów koła łowieckiego");
            }

            IList <CostPlanDto> existingEquipmentPlanDtos = _costPlanDao.GetByMarketingYear(marketingYearId);

            if (existingEquipmentPlanDtos.Any(x => x.Type == model.Type))
            {
                throw new Exception($"Plan {GetCostTypeName(model.Type)} już istnieje! Proszę użyć opcji edycji istniejącego już planu.");
            }

            var dto = new CostPlanDto
            {
                Type            = model.Type,
                Cost            = model.Cost,
                MarketingYearId = marketingYearId
            };

            _costPlanDao.Insert(dto);
        }