public EmployeeVacationRequestsViewModel GetEmployeeVacationRequests(Guid idEmployee) { EmployeeVacationRequestsViewModel employeeVacationRequestsViewModel = new EmployeeVacationRequestsViewModel(); Employee dbemployee = dbContext.Employees.FirstOrDefault(x => x.IDEmployee == idEmployee); if (dbemployee != null) { employeeVacationRequestsViewModel.FullName = dbemployee.FirstName + " " + dbemployee.LastName; employeeVacationRequestsViewModel.Position = (PositionEnum)dbemployee.Position; employeeVacationRequestsViewModel.TeamName = dbemployee.Team.Name; employeeVacationRequestsViewModel.BusinessUnitName = dbemployee.BusinessUnit.Name; employeeVacationRequestsViewModel.HiringDate = dbemployee.HiringDate; employeeVacationRequestsViewModel.TotalDaysOff = dbemployee.TotalDaysOff; employeeVacationRequestsViewModel.DaysOffLeft = dbemployee.DaysOffLeft; IQueryable <VacationRequest> dbEmployeeVacationRequests = dbContext.VacationRequests.Where(x => x.IDEmployee == idEmployee); foreach (VacationRequest dbVacation in dbEmployeeVacationRequests) { VacationRequestModel vacationRequestModel = new VacationRequestModel(); vacationRequestModel.Reason = dbVacation.Reason; vacationRequestModel.StartDate = dbVacation.StartDate; vacationRequestModel.EndDate = dbVacation.EndDate; vacationRequestModel.DaysRequested = dbVacation.DaysRequested; vacationRequestModel.FirstApproval = (ApprovalStatusEnum)dbVacation.FirstApproval; vacationRequestModel.SecondApproval = (ApprovalStatusEnum)dbVacation.SecondApproval; vacationRequestModel.Status = (ApprovalStatusEnum)dbVacation.Status; employeeVacationRequestsViewModel.EmployeeVacations.Add(vacationRequestModel); } } return(employeeVacationRequestsViewModel); }
// GET: Employee/MyProfile public ActionResult MyProfile() { if (User.Identity.IsAuthenticated) { Guid id = employeeRepository.GetEmployeeByUserId(User.Identity.GetUserId()).IDEmployee; EmployeeVacationRequestsViewModel viewModel = employeeRepository.GetEmployeeVacationRequests(id); return(View("MyProfile", viewModel)); } return(RedirectToAction("Login", "Account")); }