public ActionResult Create(TSAutoHoursRecord tsAutoHoursRecord) { if (tsAutoHoursRecord.BeginDate > tsAutoHoursRecord.EndDate) { ModelState.AddModelError("BeginDate", "Дата начала не может быть больше даты конца."); } var reportingPeriodForBeginDate = _reportingPeriodService.GetAll(x => x.Month == tsAutoHoursRecord.BeginDate.Value.Month && x.Year == tsAutoHoursRecord.BeginDate.Value.Year).FirstOrDefault(); var reportingPeriodForEndDate = _reportingPeriodService.GetAll(x => x.Month == tsAutoHoursRecord.EndDate.Value.Month && x.Year == tsAutoHoursRecord.EndDate.Value.Year).FirstOrDefault(); if (reportingPeriodForBeginDate != null && reportingPeriodForBeginDate.NewTSRecordsAllowedUntilDate < DateTime.Now) { ModelState.AddModelError("BeginDate", "Отчетный период закрыт"); } if (reportingPeriodForEndDate != null && reportingPeriodForEndDate.NewTSRecordsAllowedUntilDate < DateTime.Now) { ModelState.AddModelError("EndDate", "Отчетный период закрыт"); } if (ModelState.IsValid) { _tsAutoHoursRecordService.Add(tsAutoHoursRecord); return(RedirectToAction("Index")); } SetViewBag(null); return(View(tsAutoHoursRecord)); }
public ActionResult Create(VacationRecord vacationRecord) { var currentUser = _userService.GetUserDataForVersion(); if (vacationRecord.VacationBeginDate > vacationRecord.VacationEndDate) { ModelState.AddModelError("VacationBeginDate", "Дата начала не может быть больше даты конца."); } else if (CheckDateCrossing(vacationRecord)) { ModelState.AddModelError("VacationBeginDate", "Выберите другой день."); } else { //SKIPR-563 - временное отключение ограничения, согласно которому нельзя создать запись отпуска, если недостаточно накопленных дней отпуска /*EmployeeVacationDto employeeVacationDto = GetAvailableVacationDays(_employeeService.GetById(vacationRecord.EmployeeID)); * * if ((employeeVacationDto.AvailableVacationDays < vacationRecord.VacationDays) || (employeeVacationDto.AvailableVacationDays == 0)) * { * ModelState.AddModelError("VacationDays", "Доступных дней отпуска: " + employeeVacationDto.AvailableVacationDays); * }*/ } var reportingPeriodForBeginDate = _reportingPeriodService.GetAll(x => x.Month == vacationRecord.VacationBeginDate.Month && x.Year == vacationRecord.VacationBeginDate.Year).FirstOrDefault(); var reportingPeriodForEndDate = _reportingPeriodService.GetAll(x => x.Month == vacationRecord.VacationEndDate.Month && x.Year == vacationRecord.VacationEndDate.Year).FirstOrDefault(); if (reportingPeriodForBeginDate != null && reportingPeriodForBeginDate.NewTSRecordsAllowedUntilDate < DateTime.Now) { ModelState.AddModelError("VacationBeginDate", "Отчетный период закрыт"); } if (reportingPeriodForEndDate != null && reportingPeriodForEndDate.NewTSRecordsAllowedUntilDate < DateTime.Now) { ModelState.AddModelError("VacationEndDate", "Отчетный период закрыт"); } if (ModelState.IsValid) { vacationRecord.RecordSource = VacationRecordSource.UserInput; _vacationRecordService.Add(vacationRecord); //TODO добавить //_taskTimesheetProcessing.ProcessVacationRecords(currentEmployee, vacationRecord); return(RedirectToAction("Index")); } SetViewBag(vacationRecord); return(View(vacationRecord)); }
public ActionResult Index() { var reportingPeriods = _reportingPeriodService.GetAll().OrderBy(x => x.FullName).ToList(); return(View(reportingPeriods)); }