// 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)); }
// 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)); }
// GET: LeaveAllocationController/Details/5 public async Task <ActionResult> Details(string id) { var employee = _mapper.Map <EmployeeVM>(await _userManager.FindByIdAsync(id)); var alloctions = _mapper.Map <List <LeaveAllocationVM> >(await _leaveAllocationrepo.GetLeaveAllocationsByEmployee(id)); var model = new ViewAllocationsVM { Employee = employee, LeaveAllocations = alloctions }; return(View(model)); }
// GET: LeaveAllocationController/Details/5 public async Task <ActionResult> Details(string id) { //Because is Async, we get result var employee = _mapper.Map <EmployeeVM>(await _userManager.FindByIdAsync(id)); var allocations = _mapper.Map <List <LeaveAllocationVM> >(await _leaveAllocationRepo.FindByEmployeeId(id)); var model = new ViewAllocationsVM { Employee = employee, Allocations = allocations }; return(View(model)); }
// GET: LeaveAllocation/Details/5 public ActionResult Details(string id) { var employee = _mapper.Map <EmployeeVM>(_userManager.FindByIdAsync(id).Result); //same as above code, just one line var allocations = _mapper.Map <List <LeaveAllocationVM> > (_leaveallocationrepo.GetLeaveAllocationsByEmployee(id)); var model = new ViewAllocationsVM { Employee = employee, LeaveAllocations = allocations }; return(View(model)); }
public async Task <ActionResult> Details(string id) { var patient = _mapper.Map <PatientVM>(await _userManager.FindByIdAsync(id)); var allocations = _mapper.Map <List <TestAllocationVM> >(await _testallocationrepo.GetTestAllocationsByPatient(id)); var model = new ViewAllocationsVM { Patient = patient, TestAllocations = allocations }; return(View(model)); }
// GET: LeaveAllocationController/Details/5 public async Task <IActionResult> Details(string employeeId) { var employeeVM = mapper.Map <EmployeeVM>(await userManager.FindByIdAsync(employeeId)); var leaveAllocations = mapper.Map <List <LeaveAllocationVM> >((await leaveAllocationRepository.GetLeaveAllocationsByEmployeeId(employeeId)).ToListAsync()); var viewAllocationsVM = new ViewAllocationsVM { EmployeeVM = employeeVM, EmployeeId = employeeId, LeaveAllocationVMs = leaveAllocations }; return(View(viewAllocationsVM)); }
// GET: LeaveAllocationController/Details/5 public ActionResult Details(string id) { var emp = _userManager.FindByIdAsync(id).Result; var employee = _mapper.Map <EmployeeVM>(emp); var allocations = _mapper.Map <List <DetailLeaveAllocationVM> >(_allocaionrepo.GetLeaveAllocationsByEmployee(id).ToList()); var model = new ViewAllocationsVM { Employee = employee, LeaveAllocations = allocations }; return(View(model)); }
// 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)); }
// GET: LeaveAllocationController/Details/5 public async Task <ActionResult> Details(string id) { var employee = _mapper.Map <EmployeeVM>(await _userManager.FindByIdAsync(id)); var period = DateTime.Now.Year; var allocations = _mapper.Map <List <LeaveAllocationVM> >(await _unitOfWork.LeaveAllocations.FindAll(expression: q => q.EmployeeId == id && q.Period == period, includes: new List <string> { "LeaveType" })); var model = new ViewAllocationsVM { Employee = employee, LeaveAllocations = allocations }; return(View(model)); }
// GET: LeaveAllocationController/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 _leaveAllocationRepo.GetLeaveAllocationsByEmployee(id)); var records = _unitOfWork.LeaveAllocations.FindAll(_ => _.EmployeeId == id && _.Period == DateTime.Now.Year, includes: new List <string>() { "LeaveType" }); var allocations = _mapper.Map <List <LeaveAllocationVM> >(records); var model = new ViewAllocationsVM { Employee = employee, LeaveAllocations = allocations }; return(View(model)); }