public JsonResult Edit(EmploymentPlanViewModel model, int marketingYearId) { string message = String.Empty; try { _employmentPlanService.UpdateEmploymentPlan(model, marketingYearId); } catch (Exception ex) { message = ex.Message; } return(Json(new { message }, JsonRequestBehavior.AllowGet)); }
public void UpdateEmploymentPlan(EmploymentPlanViewModel model, int marketingYearId) { if (model.EmploymentType <= 0) { throw new Exception("Nie można edytować planu gospodarczego zatrudnienia"); } var dto = new EmploymentPlanDto { EmploymentType = model.EmploymentType, Count = model.Count, MarketingYearId = marketingYearId }; _employmentPlanDao.Update(dto); }
public void AddEmploymentPlan(EmploymentPlanViewModel model, int marketingYearId) { if (model.EmploymentType == 0) { throw new Exception("Nie można dodać planu gospodarczego zatrudnienia"); } IList <EmploymentPlanDto> existingEquipmentPlanDtos = _employmentPlanDao.GetByMarketingYear(marketingYearId); if (existingEquipmentPlanDtos.Any(x => x.EmploymentType == model.EmploymentType)) { throw new Exception($"Plan zatrudnienia {GetEmploymentTypeName(model.EmploymentType)} już istnieje! Proszę użyć opcji edycji istniejącego już planu."); } var dto = new EmploymentPlanDto { EmploymentType = model.EmploymentType, Count = model.Count, MarketingYearId = marketingYearId }; _employmentPlanDao.Insert(dto); }