// GET: LeaveAllocationController/Details/5
        public async Task <ActionResult> Details(string id)
        {
            var user = await _userManager.FindByIdAsync(id);

            var currentUser = _userManager.GetUserAsync(User).Result;

            if ((User.IsInRole("Nhân viên") || User.IsInRole("Kế toán")) &&
                currentUser.Id != id)
            {
                return(NotFound("Nhân viên bình thường chỉ có thể xem hồ sơ mật của mình, không thể xem hồ sơ của người khác."));
            }

            var employee = _mapper.Map <EmployeeVM>(user);

            employee.NhanVienThemVaoHeThong = _mapper.Map <EmployeeVM>(await _userManager.FindByIdAsync(user.MaNhanVienThemVaoHeThong));
            employee.ChucVu    = _mapper.Map <ChucVusVM>(await _chucVuRepo.FindById(user.MaChucVu));
            employee.ChuyenMon = _mapper.Map <ChuyenMonsVM>(await _chuyenMonRepo.FindById(user.MaChuyenMon));
            employee.PhongBan  = _mapper.Map <PhongBansVM>(await _phongBanRep.FindById(user.MaPhongBan));

            var maVaiTroTrenHeThong = await userRoleRepository.FindRoleIdByUserID(employee.Id);

            employee.VaiTroTrenHeThong = await _roleRepository.FindById(maVaiTroTrenHeThong);

            var allocations = _mapper.Map <List <LeaveAllocationVM> >(
                await _leaveallocationrepo.GetLeaveAllocationsByEmployee(id));


            var model = new ViewAllocationsVM
            {
                Employee         = employee,
                LeaveAllocations = allocations,
            };

            return(View(model));
        }
        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));
        }
Esempio n. 3
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());
            }
        }
        // GET: LeaveRequestController/Create
        public async Task <ActionResult> Create()
        {
            var userId             = _userManager.GetUserAsync(User).Result.Id;
            var EmployeeAllocation = await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(userId);

            var list = new List <LeaveType>();

            foreach (var item in EmployeeAllocation.ToList())
            {
                list.Add(item.LeaveType);
            }

            var leaveTypeItems = list.Select(q => new SelectListItem {
                Text  = q.Name,
                Value = q.Id.ToString()
            });



            var model = new CreateLeaveRequestVm
            {
                LeaveTypes = leaveTypeItems
            };

            return(View(model));
        }
Esempio n. 6
0
        // GET: LeaveAllocation/Details/5
        public async Task <ActionResult> Details(string id)
        {
            var employee    = _mapper.Map <EmployeeVM>(await _userManager.FindByIdAsync(id));
            var allocations = _mapper.Map <List <LeaveAllocationVM> >(await _repoleaveAllocation.GetLeaveAllocationsByEmployee(id));
            var model       = new ViewAllocationVM {
                Employee = employee, LeaveAllocationVMs = allocations
            };

            return(View(model));
        }
        // GET: LeaveAllocationsController1/Details/5
        public ActionResult Details(string id)
        {
            var model = new ViewAllocationsVM
            {
                Employee         = _mapper.Map <EmployeeVM>(_userManager.FindByIdAsync(id).Result),
                LeaveAllocations = _mapper.Map <ICollection <LeaveAllocationVM> >(_leaveAllocationRepo.GetLeaveAllocationsByEmployee(id))
            };

            return(View(model));
        }
Esempio n. 8
0
        public async Task <ActionResult> MyLeave()
        {
            var EmployeeId = _userManager.GetUserAsync(User).Result.Id;
            var requests   = await _requestRepo.GetLeaveRequestByEmployee(EmployeeId);

            var allocations = await _allocationRepo.GetLeaveAllocationsByEmployee(EmployeeId);

            var MappedAllocations = _mapper.Map <List <LeaveAllocationVM> >(allocations.ToList());
            var MappedRequest     = _mapper.Map <List <LeaveRequestVM> >(requests.ToList());



            var model = new MyEmployeeLeaveVM
            {
                LeaveAllocations = MappedAllocations,
                LeaveRequests    = MappedRequest
            };

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

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

            var employeeRequests = await _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeid);

            var employeeAllocationModel = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
            var employeeRequestModel    = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);

            var model = new EmployeeLeaveRequestViewVM
            {
                LeaveAllocations = employeeAllocationModel,
                LeaveRequests    = employeeRequestModel
            };

            return(View(model));
        }
        // GET: LeaveAllocation/Details/5
        public ActionResult Details(string id)
        {
            var employee    = _mapper.Map <EmployeeVM>(_userManager.FindByIdAsync(id).Result);
            var allocations = _mapper.Map <List <LeaveAllocationVM> >(_allocationRepo.GetLeaveAllocationsByEmployee(id));
            var model       = new ViewAllocationVM {
                Employee         = employee,
                LeaveAllocations = allocations
            };

            return(View(model));
        }
        // GET: LeaveAllocation/Details/5
        public ActionResult Details(string id)
        {
            var employee    = _mapper.Map <EmployeeViewModel>(_userManager.FindByIdAsync(id).Result);
            var allocations = _repository.GetLeaveAllocationsByEmployee(id);
            var model       = new ViewAllocationsViewModel
            {
                Employee         = employee,
                LeaveAllocations = _mapper.Map <List <LeaveAllocationViewModel> >(allocations)
            };

            return(View(model));
        }
        // GET: LeaveAllocationController/Details/5
        public async Task <ActionResult> Details(string id)
        {
            var employee    = _mapper.Map <EmployeeViewModel>(_userManager.FindByIdAsync(id).Result);
            var allocations = _mapper.Map <List <LeaveAllocationViewModel> >(await _allocationrepo.GetLeaveAllocationsByEmployee(id));
            var model       = new ViewLeaveAllocationsViewModel
            {
                Employee        = employee,
                LeaveAllocation = allocations
            };

            return(View(model));
        }
Esempio n. 13
0
        // GET: LeaveAllocationCotroller/Details/5
        public ActionResult Details(string id)
        {
            var employee    = _mapper.Map <EmployeeViewModel>(_userManager.FindByIdAsync(id).Result);
            var period      = DateTime.Now;
            var allocations = _mapper.Map <List <LeaveAllocationViewModel> >(_leaveallocationrepo.GetLeaveAllocationsByEmployee(id));
            var model       = new ViewAllocationViewModel
            {
                Employee         = employee,
                LeaveAllocations = allocations
            };

            return(View(model));
        }
        // GET: LeaveAllocation/Details/5
        public async Task <ActionResult> Details(string id)                                                                          //from int to string
        {
            var employee = _mapper.Map <EmployeeVM>(await _userManager.FindByIdAsync(id));                                           //whenever we get data we need map it
            //retrive all the leave allocation for this employee
            var allocations = _mapper.Map <List <LeaveAllocationVM> >(await _leaveallocationrepo.GetLeaveAllocationsByEmployee(id)); //list to VM
            var model       = new ViewAllocationVM
            {
                Employee         = employee,
                LeaveAllocations = allocations
            };

            return(View(model));
        }
Esempio n. 15
0
        // GET: LeaveAllocations/Details/5
        public ActionResult Details(string id)
        {
            // We need result when it's async
            var employee    = _mapper.Map <EmployeeViewModel>(_userManager.FindByIdAsync(id).Result);
            var allocations = _mapper.Map <List <LeaveAllocationViewModel> >(_leaveAllocationrepo.GetLeaveAllocationsByEmployee(id));
            var model       = new ViewAllocationsVM
            {
                Employee         = employee,
                LeaveAllocations = allocations
            };

            return(View(model));
        }
        public IActionResult MyLeave()
        {
            var leaveRequests    = _leaveRequestRepository.FindAll().Where(x => x.RequestingEmployee.Id == _userManager.GetUserAsync(User).Result.Id);
            var leaveAllocations = _leaveAllocationRepository.GetLeaveAllocationsByEmployee(_userManager.GetUserAsync(User).Result.Id);

            var model = new EmployeeLeaveRequestViewModel
            {
                leaveRequests    = leaveRequests,
                leaveAllocations = leaveAllocations
            };

            return(View(model));
        }
Esempio n. 17
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));
        }
        // GET: LeaveAllocationController/Details/5
        public ActionResult Details(string id)
        {
            //var employee = _mapper.Map<EmployeeVM>(_userManager.FindByIdAsync(id).Result);
            //var allocations = _mapper.Map <List<LeaveAllocationVM>>(_Allocationrepo.GetLeaveAllocationsByEmployee(id));
            //var model = new ViewAllocationsVM
            //{
            //    Employee = employee,
            //    LeaveAllocations = allocations
            //};

            var employee = _userManager.FindByIdAsync(id).Result;

            employee.LeaveAllocations = _Allocationrepo.GetLeaveAllocationsByEmployee(id);
            var model = _mapper.Map <ViewAllocationsVM>(employee);

            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));
        }
        // GET: LeaveAllocationController/Details/5
        public async Task <ActionResult> Details(string id)
        {
            var employee = await _userManager.FindByIdAsync(id);

            var employeeVM  = _mapper.Map <EmployeeVM>(employee);
            var period      = DateTime.Now.Year;
            var allocations = await _leaveAllocationRepository.GetLeaveAllocationsByEmployee(employee.Id);

            var allocationVMs = _mapper.Map <List <LeaveAllocationVM> >(allocations);
            var model         = new ViewAllocationVM
            {
                Employee           = employeeVM,
                LeaveAllocationVMs = allocationVMs
            };

            return(View(model));
        }
        public ActionResult MyLeave()
        {
            var employee = _userManager.GetUserAsync(User).Result;

            var leaveallocation      = _AllocationRepo.GetLeaveAllocationsByEmployee(employee.Id);
            var leaveallocationModel = _mapper.Map <List <LeaveAllocationVM> >(leaveallocation);

            var leaverequest      = _LeaveRequestRepo.GetLeaveRequestByEmployeeID(employee.Id);
            var leaverequestModel = _mapper.Map <List <LeaveRequestVM> >(leaverequest);

            var model = new MyLeaveVM
            {
                LeaveAllocations = leaveallocationModel,
                LeaveRequests    = leaverequestModel
            };

            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));
        }
Esempio n. 25
0
        public async Task <ActionResult> MyLeave(int id)
        {
            var employee = await _userManager.GetUserAsync(User);

            var leaveRequestsTask = await _leaverequestrepo.FindAll();

            var leaveRequests      = leaveRequestsTask.Where(q => q.RequestingEmployeeId == employee.Id);
            var leaveRequestsModel = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests);
            var leaveAllocations   = await _leaveallocationrepo.GetLeaveAllocationsByEmployee(employee.Id);

            var leaveAllocationsModel = _mapper.Map <List <LeaveAllocationViewModel> >(leaveAllocations);
            var model = new EmployeeLeaveRequestViewModel
            {
                LeaveAllocations = leaveAllocationsModel,
                LeaveRequests    = leaveRequestsModel
            };

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

            var employeeId    = employee.Id;
            var leaveRequests = await _requestRepo.GetLeaveRequestsByEmployee(employeeId);

            var allocations = await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employeeId);

            var leaveRequestsModel    = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests);
            var leaveAllocationsModel = _mapper.Map <List <LeaveAllocationViewModel> >(allocations);

            var model = new MyLeaveRequestViewModel
            {
                LeaveAllocations = leaveAllocationsModel,
                LeaveRequests    = leaveRequestsModel
            };

            return(View(model));
        }
        // GET: LeaveAllocationController/Details/5
        public async Task <ActionResult> Details(string Id)
        {
            EmployeeViewModel employee = _mapper
                                         .Map <EmployeeViewModel>(
                await _userManager.FindByIdAsync(Id)
                );

            List <LeaveAllocationViewModel> allcations = _mapper
                                                         .Map <List <LeaveAllocationViewModel> >(
                await _leaveallocationrepo.GetLeaveAllocationsByEmployee(Id)
                );

            ViewAllocationsViewModel model = new ViewAllocationsViewModel
            {
                Employee         = employee,
                LeaveAllocations = allcations
            };

            return(View(model));
        }
Esempio n. 28
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)));
            }
        }
        // GET: LeaveAllocation/Details/5
        public async Task <ActionResult> Details(string id)
        {
            var employee    = _mapper.Map <Employee, EmployeeVM>(await _userManager.FindByIdAsync(id));
            var allocations = _mapper.Map <ICollection <LeaveAllocation>, List <LeaveAllocationVM> >(await _leaveallocationrepo.GetLeaveAllocationsByEmployee(employee.Id));
            var model       = new ViewLeaveAllocationVM
            {
                Employee        = employee,
                LeaveAllocation = allocations
            };

            return(View(model));
        }