public async Task <IActionResult> CreateVacation(int doctorId, VacationForCreateDto vacationForCreateDto) { var vacation = _mapper.Map <Vacation>(vacationForCreateDto); if (vacation.CountDays <= 0 && vacation.StartVacation <= DateTime.Now) { return(BadRequest("Неверная начальная дата отпуска.")); } _vacationService.Add(vacation); if (await _vacationService.SaveAllAsync()) { return(NoContent()); } throw new Exception("Ошибка в ходе создания отпуска, обратитесь к администратору."); }
public ActionResult Vacation(VacationVm vm) { if (ModelState.IsValid) { Vacation model = new Vacation() { UserId = vm.UserId, Username = vm.Username, StartDate = vm.StartDate, EndDate = vm.EndDate, Status = Status.Pending }; vacationService.Add(model); ViewBag.Success = "Your request was successfully sent!"; } return(View(vm)); }