public async Task <ActionResult> MyLeave()
        {
            Employee employee = await _userManager.GetUserAsync(User);

            string employeeId = employee.Id;

            ICollection <LeaveAllocation> employeeAllocations = await _leaveAllocationRepo
                                                                .GetLeaveAllocationsByEmployee(employeeId);

            ICollection <LeaveRequest> employeeRequests = await _leaveRequestRepo
                                                          .GetLeaveRequestsByEmployee(employeeId);

            List <LeaveAllocationViewModel> employeeAllocationsModel = _mapper
                                                                       .Map <List <LeaveAllocationViewModel> >(employeeAllocations);

            List <LeaveRequestViewModel> employeeRequestsModel = _mapper
                                                                 .Map <List <LeaveRequestViewModel> >(employeeRequests);

            EmployeeLeaveRequestViewViewModel model = new EmployeeLeaveRequestViewViewModel
            {
                LeaveAllocations = employeeAllocationsModel,
                LeaveRequests    = employeeRequestsModel
            };

            return(View(model));
        }
Beispiel #2
0
        public async Task <ActionResult> MyLeave()
        {
            try
            {
                var user        = _userManager.GetUserAsync(User).Result;
                var userId      = user.Id;
                var allocations = await _allocationsRepo.GetLeaveAllocationsByEmployee(userId);

                var employeeRequests = await _leaveRequestRepo.GetLeaveRequestsByEmployee(userId);

                var employeeAllocationModel = _mapper.Map <List <LeaveAllocationViewModel> >(allocations);
                var employeeRequestsModel   = _mapper.Map <List <LeaveRequestViewModel> >(employeeRequests);

                var model = new EmployeeViewLeaveRequestViewModel
                {
                    LeaveAllocations = employeeAllocationModel,
                    LeaveRequesrts   = employeeRequestsModel
                };

                return(View(model));
            }
            catch (Exception)
            {
                return(RedirectToAction(nameof(Index), "Home"));
            }
        }
        public async Task <ActionResult> MyLeave()
        {
            try
            {
                var employee = await _userManager.GetUserAsync(User);

                var employeeid          = employee.Id;
                var employeeAllocations = await _repoleaveallocation.GetLeaveAllocationsByEmployee(employeeid);

                var employeeRequests = await _repoleaverequest.GetLeaveRequestsByEmployee(employeeid);

                var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
                var employeeRequestsModel    = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);
                var model = new EmployeeLeaveRequestVM
                {
                    LeaveAllocations = employeeAllocationsModel,
                    LeaveRequests    = employeeRequestsModel
                };
                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #4
0
        public IActionResult MyLeave()
        {
            var user = _userManager.GetUserAsync(User).Result;
            var employeeLeaveAllocations = _leaveAllocationRepo.GetLeaveAllocationsByEmployee(user.Id);
            var employeeLeaveRequests    = _leaveRequestRepo.GetLeaveRequestsByEmployee(user.Id);

            var model = new EmployeeLeaveRequestViewVM
            {
                LeaveAllocations = _mapper.Map <List <LeaveAllocationVM> >(employeeLeaveAllocations),
                LeaveRequests    = _mapper.Map <List <LeaveRequestVM> >(employeeLeaveRequests)
            };

            return(View(model));
        }
        public ActionResult MyLeave()
        {
            var employee                 = _userManager.GetUserAsync(User).Result;
            var employeeId               = employee.Id;
            var employeeAllocations      = _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employeeId);
            var employeeRequests         = _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeId);
            var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
            var employeeRequestsModel    = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);
            var model = new EmployeeLeaveRequestVM
            {
                LeaveAllocations = employeeAllocationsModel,
                LeaveRequests    = employeeRequestsModel
            };

            return(View(model));
        }
        public async Task <ActionResult> EmployeeIndex()
        {
            var employeeId      = _userManager.GetUserId(User);
            var leaveRequestObj = await _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeId);

            var leaveAllocationobj = await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employeeId);

            var leaveAllocationsVm = _mapper.Map <List <LeaveAllocationVM> >(leaveAllocationobj);
            var leaveRequestVm     = _mapper.Map <List <LeaveRequestVm> >(leaveRequestObj);
            var model = new EmployeeLeaveRequestsVM
            {
                LeaveRequests    = leaveRequestVm,
                LeaveAllocations = leaveAllocationsVm
            };

            return(View(model));
        }
        public async Task <ActionResult> MyLeave()
        {
            var employee = await _userManager.GetUserAsync(User);

            var leaveAllocations =
                _mapper.Map <List <LeaveAllocationVM> >(await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employee.Id));
            var leaveRequests =
                _mapper.Map <List <LeaveRequestVM> >(await _leaveRequestRepo.GetLeaveRequestsByEmployee(employee.Id));


            EmployeeLeaveRequestVM model = new EmployeeLeaveRequestVM
            {
                LeaveAllocations = leaveAllocations,
                LeaveRequests    = leaveRequests
            };

            return(View(model));
        }
        public ActionResult UserLeaveRequests()
        {
            var user       = _userManager.GetUserAsync(User).Result;
            var employeeId = user.Id;

            var userAllocations = _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employeeId);
            var userRequests    = _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeId);

            var userAllocationModel = _mapper.Map <List <LeaveAllocationViewModel> >(userAllocations);
            var userRequestModel    = _mapper.Map <List <LeaveRequestViewModel> >(userRequests);

            var model = new EmployeeLeaveRequestsViewModel
            {
                LeaveAllocations = userAllocationModel,
                LeaveRequests    = userRequestModel
            };

            return(View(model));
        }
        public async Task <ActionResult> MyLeave()
        {
            var employee = await _userManager.GetUserAsync(User);

            var employeeAllocations = await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employee.Id);

            var employeeRequests = await _leaveRequestRepo.GetLeaveRequestsByEmployee(employee.Id);

            var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationViewModel> >(employeeAllocations);
            var employeeRequestsModel    = _mapper.Map <List <LeaveRequestViewModel> >(employeeRequests);

            var model = new EmployeeLeaveRequestViewModel
            {
                LeaveAllocations = employeeAllocationsModel,
                LeaveRequests    = employeeRequestsModel
            };

            return(View(model));
        }
Beispiel #10
0
        public async Task <ActionResult> MyLeave()
        {
            try
            {
                var employee = await _userManager.GetUserAsync(User);

                var employeeId = employee.Id;

                var leaveAllocations = await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employeeId);

                var leaveRequests = await _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeId);

                var model = new EmployeeLeaveRequestViewVM
                {
                    LeaveAllocations = _mapper.Map <List <LeaveAllocationVM> >(leaveAllocations),
                    LeaveRequests    = _mapper.Map <List <LeaveRequestVM> >(leaveRequests)
                };
                return(View(model));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task <ActionResult> MyLeave()
        {
            try
            {
                var user = await _userManager.GetUserAsync(User);


                var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationViewModel> >(await _leaveaAllocationrepo.GetLeaveAllocationByEmployee(user.Id));
                var employeeRequestsModel    = _mapper.Map <List <LeaveRequestViewModel> >(await _leaveaRequestrepo.GetLeaveRequestsByEmployee(user.Id));

                var model = new EmployeeLeaveRequestViewModel
                {
                    LeaveAllocations = employeeAllocationsModel,
                    LeaveRequests    = employeeRequestsModel
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(Index)));
            }
        }