Exemplo n.º 1
0
        public void EditVac([Bind(Include = "Id, UserId, Status")] VacationVm request)
        {
            Vacation model = new Vacation();

            model = vacationService.GetVacationById(request.Id);

            model.Id     = request.Id;
            model.UserId = request.UserId;
            model.Status = request.Status;

            vacationService.Update(model);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        public ActionResult Vacation(int id)
        {
            UserModel user  = new UserModel();
            var       model = new VacationVm();

            user           = userService.GetUser(id);
            model.UserId   = user.UserId;
            model.Username = user.Username;

            Vacation vm = new Vacation();

            vm = vacationService.GetVacationByUserId(model.UserId);

            var vacations = vacationService.GetAllVacations().Where(m => m.UserId == id);

            foreach (var item in vacations)
            {
                if (item?.Status == Status.Accepted)
                {
                    ViewBag.Approved = "Your vacation request from " + item.StartDate + " to " + item.EndDate + " was approved!";
                }
                else if (item?.Status == Status.Rejected)
                {
                    ViewBag.Rejected = "Your vacation request from " + item.StartDate + " to " + item.EndDate + " was rejected!";
                }
                else if (item?.Status == Status.Pending)
                {
                    ViewBag.Pending = "Your request is pending!";
                }
                else
                {
                    ViewBag.NoValue = " ";
                }
            }

            return(View(model));
        }