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

            try
            {
                _huntEquipmentPlanService.UpdateHuntEquipmentPlan(model, marketingYearId);
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(Json(new { message }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public void UpdateHuntEquipmentPlan(HuntEquipmentPlanViewModel model, int marketingYearId)
        {
            if (model.Type <= 0)
            {
                throw new Exception("Nie można edytować planu urządzenia łowieckiego");
            }

            var dto = new HuntEquipmentPlanDto
            {
                Type            = model.Type,
                Count           = model.Count,
                MarketingYearId = marketingYearId
            };

            _huntEquipmentPlanDao.Update(dto);
        }
Esempio n. 3
0
        public void AddHuntEquipmentPlan(HuntEquipmentPlanViewModel model, int marketingYearId)
        {
            if (model.Type == 0)
            {
                throw new Exception("Nie można dodać planu urządzenia łowieckiego");
            }

            IList <HuntEquipmentPlanDto> existingEquipmentPlanDtos = _huntEquipmentPlanDao.GetByMarketingYear(marketingYearId);

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

            var dto = new HuntEquipmentPlanDto
            {
                Type            = model.Type,
                Count           = model.Count,
                MarketingYearId = marketingYearId
            };

            _huntEquipmentPlanDao.Insert(dto);
        }