Ejemplo n.º 1
0
        public async Task <ActionResult> MyLeave()
        {
            var employee = await _userManager.GetUserAsync(User);


            var leaveRequests = (await _leaveRequestRepo.FindAll())
                                .Where(q => q.RequestingEmployeeId == employee.Id);
            var leaveAllocations = (await _leaveAllocationRepo.FindAll())
                                   .Where(q => q.EmployeeId == employee.Id);

            var leaveAllocationsIds = (await _leaveAllocationRepo.FindAll())
                                      .Where(q => q.EmployeeId == employee.Id.ToString())
                                      .Select(q => q.LeaveTypeId);
            var leaveTypeInfo = (await _leaveTypeRepo.FindAll())
                                .Where(q => leaveAllocationsIds.Contains(q.Id));



            var leaveRequestsVM    = _mapper.Map <List <LeaveRequestVM> >(leaveRequests);
            var leaveAllocationsVM = _mapper.Map <List <LeaveAllocationVM> >(leaveAllocations);
            var leaveTypeInfoVM    = _mapper.Map <List <LeaveTypeVM> >(leaveTypeInfo);



            var model = new EmployeeLeaveRequestViewVM
            {
                LeaveRequests    = leaveRequestsVM,
                LeaveAllocations = leaveAllocationsVM,
                LeaveTypesInfo   = leaveTypeInfoVM
            };

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

            var employeeid = employee.Id;

            var employeeAllocations = await _unitOfWork.LeaveAllocations.FindAll(q => q.EmployeeId == employeeid,
                                                                                 includes : new List <string> {
                "LeaveType"
            });

            var employeeRequests = await _unitOfWork.LeaveRequests
                                   .FindAll(q => q.RequestingEmployeeId == employeeid);

            var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
            var employeeRequestsModel    = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);

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

            return(View(model));
        }
        public async Task <IActionResult> MyLeave()
        {
            var employeeId = userManager.GetUserId(HttpContext.User);
            var employeeLeaveAllocations = await unitOfWork.LeaveAllocations.FindAll(x => x.EmployeeId == employeeId && x.Period == DateTime.Now.Year, includes : new List <string>()
            {
                nameof(LeaveType), nameof(Employee)
            });

            var employeeLeaveRequests = await unitOfWork.LeaveRequests.FindAll(
                x => x.RequestingEmployeeId == employeeId,
                includes : new List <string>()
            {
                nameof(LeaveRequest.RequestingEmployee), nameof(LeaveRequest.ApprovedBy), nameof(LeaveRequest.LeaveType)
            });

            var employeeAllocationVMs = mapper.Map <List <LeaveAllocationVM> >(employeeLeaveAllocations);
            var employeeRequestsVMs   = mapper.Map <List <LeaveRequestVM> >(employeeLeaveRequests);

            var employeeLeaveRequestsViewVM = new EmployeeLeaveRequestViewVM
            {
                LeaveAllocationVMs = employeeAllocationVMs,
                LeaveRequestVMs    = employeeRequestsVMs
            };

            return(View(employeeLeaveRequestsViewVM));
        }
Ejemplo n.º 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  = _leaveAllocRepo.GetLeaveAllocationsByEmployee(employeeId);
            var employeeRequests     = _leaveRequestRepo.GetLeaveRequestByEmployee(employeeId);
            var employeeAllocModel   = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
            var employeeRequestModel = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);
            var model = new EmployeeLeaveRequestViewVM
            {
                LeaveAllocations = employeeAllocModel,
                LeaveRequests    = employeeRequestModel
            };

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

            var employeeid          = employee.Id;
            var employeeAllocations = _leaveAllocRepo.GetLeaveAllocationsByEmployee(employeeid);
            var employeeRequests    = _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeid);

            var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
            var employeeRequestsModel    = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);

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

            return(View(model));
        }
Ejemplo n.º 7
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)));
            }
        }