Exemple #1
0
 public IActionResult Add(VacationsMovement vacationsMovement)
 {
     if (!ModelState.IsValid)
     {
         NewVacationsMovementViewModel viewModel = new NewVacationsMovementViewModel()
         {
             Attorneys = _attorneysRepo.Attorneys
         };
         viewModel.VacationsMovement = vacationsMovement;
         return(View(viewModel));
     }
     else
     {
         if (_vacationsMovementRepo.ValidateMovement(vacationsMovement))
         {
             var user   = HttpContext.User;
             int userId = Convert.ToInt32(user.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
             _vacationsMovementRepo.Save(vacationsMovement, userId);
             ViewBag.DaysInvalid = false;
             TempData["added"]   = true;
             return(RedirectToAction("Add"));
         }
         else
         {
             ViewBag.DaysInvalid = true;
             NewVacationsMovementViewModel viewModel = new NewVacationsMovementViewModel()
             {
                 Attorneys = _attorneysRepo.Attorneys
             };
             viewModel.VacationsMovement = vacationsMovement;
             return(View(viewModel));
         }
     }
 }
Exemple #2
0
        public IActionResult Add()
        {
            var attorneys = _attorneysRepo.Attorneys.Where(a => a.User.Active).ToList();

            foreach (var a in attorneys)
            {
                a.AvailableVacationCount = _vacationsRequestRepo.GetAvailableVacationCount(a.UserId);
            }
            NewVacationsMovementViewModel viewModel = new NewVacationsMovementViewModel
            {
                Attorneys         = attorneys,
                VacationsMovement = new VacationsMovement()
            };

            ViewBag.AddedMovement = TempData["added"];
            ViewBag.DaysInvalid   = false;
            return(View(viewModel));
        }