public ValidationMessageCollection ValidateBook(BookHolidayRequest request)
 {
     using (var transactionScope = new TransactionScope())
     {
         var employee = _employeeRepository.GetById(request.EmployeeId);
         var validationMessages = Holiday.ValidateBook(employee, request.Start, request.End);
         transactionScope.Complete();
         return validationMessages;
     }
 }
 public void Book(BookHolidayRequest request)
 {
     using (var transactionScope = new TransactionScope())
     {
         var employee = _employeeRepository.GetById(request.EmployeeId);
         DomainEvents.Register<HolidayBookedEvent>(HolidayBooked);
         Holiday.Book(request.Id, employee, request.Start, request.End);
         _employeeRepository.Flush();
         transactionScope.Complete();
     }
 }
        public ActionResult BookUpdate(BookHolidayViewModel viewModel)
        {
            if (viewModel.Updating)
            {
                var updateHolidayRequest = new UpdateHolidayRequest
                {
                    Id = viewModel.HolidayId.Value,
                    Start = viewModel.Start,
                    End = viewModel.End
                };

                var validationResult = _holidayService.ValidateUpdate(updateHolidayRequest);

                if (!validationResult.IsValid)
                {
                    foreach (var error in validationResult.Errors)
                        ModelState.AddModelError(error.Field ?? "", error.Text);

                    return View("BookUpdate", viewModel);
                }

                _holidayService.Update(updateHolidayRequest);
            }
            else
            {
                Guid id = Guid.NewGuid();

                var bookHolidayRequest = new BookHolidayRequest
                {
                    Id = id,
                    EmployeeId = viewModel.EmployeeId.Value,
                    Start = viewModel.Start,
                    End = viewModel.End
                };

                var validationResult = _holidayService.ValidateBook(bookHolidayRequest);

                if (!validationResult.IsValid)
                {
                    foreach (var error in validationResult.Errors)
                        ModelState.AddModelError(error.Field ?? "", error.Text);

                    return View("BookUpdate", viewModel);
                }

                _holidayService.Book(bookHolidayRequest);
            }

            return RedirectToAction("Index", "Employee", new { employeeId = viewModel.EmployeeId });
        }