// GET: Employee public ActionResult Index(int?id, int?ContractID) { var viewModel = new EmployeeIndexData(); viewModel.Employees = db.Employees .Include(i => i.Contracts.Select(c => c.Job)) .OrderBy(i => i.ID); if (id != null) { ViewBag.EmployeeID = id.Value; viewModel.Contracts = viewModel.Employees.Where( i => i.ID == id.Value).Single().Contracts; } if (ContractID != null) { ViewBag.ContractID = ContractID.Value; //commented out next three lines because doing using explicit loading // viewModel.Allocations = viewModel.Contracts.Where( // x => x.ContractID == ContractID).Single().Allocations; //explicit loading var selectedContract = viewModel.Contracts.Where(x => x.ContractID == ContractID).Single(); db.Entry(selectedContract).Collection(x => x.Allocations).Load(); foreach (Allocation allocation in selectedContract.Allocations) { db.Entry(allocation).Reference(x => x.Project).Load(); } viewModel.Allocations = selectedContract.Allocations; } return(View(viewModel)); }
// GET: Employees public async Task <IActionResult> Index(int?id, int?serviceID) { var viewModel = new EmployeeIndexData(); viewModel.Employees = await _context.Employees .Include(i => i.OfficeAssignment) .Include(i => i.ServiceAssignments).ThenInclude(i => i.Service).ThenInclude(i => i.Schedules).ThenInclude(i => i.Patient) .Include(i => i.ServiceAssignments).ThenInclude(i => i.Service).ThenInclude(i => i.Department) .AsNoTracking().OrderBy(i => i.FirstName).ToListAsync(); if (id != null) { ViewData["EmployeeID"] = id.Value; Employee employee = viewModel.Employees.Where( i => i.ID == id.Value).Single(); viewModel.Services = employee.ServiceAssignments.Select(s => s.Service); } if (serviceID != null) { ViewData["ServiceID"] = serviceID.Value; var selectedService = viewModel.Services.Where(x => x.ServiceID == serviceID).Single(); await _context.Entry(selectedService).Collection(x => x.Schedules).LoadAsync(); foreach (Schedule schedule in selectedService.Schedules) { await _context.Entry(schedule).Reference(x => x.Patient).LoadAsync(); } viewModel.Schedules = selectedService.Schedules; } return(View(viewModel)); }
public ActionResult HistoryReport(int?id) { var employees = from s in db.Employees.Include(e => e.EmployeeStatus.Select(c => c.HeritageCompany)) .Include(e => e.EmployeeStatus.Select(c => c.LegalCompany)) .Include(e => e.EmployeeStatus.Select(c => c.EmployeeStatus)) .Include(e => e.EmployeeStatus.Select(c => c.EmployeeType)) .Include(e => e.EmployeeStatus.Select(c => c.OverTimeStatus)) .Include(e => e.EmployeeStatus.Select(c => c.UnionStatus)) .Include(e => e.Compensations.Select(c => c.CompensationType)) .Include(e => e.Compensations.Select(c => c.Currency)) .Include(e => e.Careers.Select(c => c.Department)) .Include(e => e.Careers.Select(c => c.BudgetArea)) .Include(e => e.Benefits.Select(c => c.BenefitType)) .Include(e => e.Trainings.Select(c => c.TrainingType)) .Include(e => e.Trainings.Select(c => c.TrainingCategory)) .Include(e => e.ParkingAccesses.Select(c => c.Parking)) .Include(e => e.BuildingAccesses.Select(c => c.Building)) .OrderBy(i => i.LastName) select s; var viewModel = new EmployeeIndexData(); if (!id.Equals(null)) { ViewBag.EmployeeID = id.Value; viewModel.Status = employees.Where( i => i.EmployeeID == id.Value).Single().EmployeeStatus; viewModel.Compensations = employees.Where( i => i.EmployeeID == id.Value).Single().Compensations; viewModel.Careers = employees.Where( i => i.EmployeeID == id.Value).Single().Careers; viewModel.Benefits = employees.Where( i => i.EmployeeID == id.Value).Single().Benefits; viewModel.Trainings = employees.Where( i => i.EmployeeID == id.Value).Single().Trainings; viewModel.ParkingAccesses = employees.Where( i => i.EmployeeID == id.Value).Single().ParkingAccesses; viewModel.BuildingAccesses = employees.Where( i => i.EmployeeID == id.Value).Single().BuildingAccesses; ViewBag.FullName = employees.Where( i => i.EmployeeID == id.Value).Single().FullName; } return(View(viewModel)); }
public async Task OnGetAsync(int?id, int?employeeID) { EmployeeData = new EmployeeIndexData(); EmployeeData.Employees = await _context.Employees .Include(i => i.EmployeeTerritories) .ThenInclude(i => i.Territory) .AsNoTracking() .OrderBy(i => i.LastName) .ToArrayAsync(); if (id != null) { EmployeeID = id.Value; Employee employee = EmployeeData.Employees.Single( i => i.EmployeeId == id.Value); EmployeeData.Territories = employee.EmployeeTerritories.Select(s => s.Territory); //s.TerritoryId } }
public async Task OnGetAsync(int?id, string message) { if (message != null) { ModelState.AddModelError(string.Empty, message); } Employee = new EmployeeIndexData(); Employee.Employees = await _context.Employee .Include(e => e.User) .Include(e => e.TreatmentAssignments) .ThenInclude(e => e.Enrollments) .AsNoTracking() .OrderBy(e => e.Id) .ToListAsync(); if (id != null) { //EmployeeID = id.Value; Employee.Enrollments = await _context.Enrollment .Where(s => s.TreatmentAssignment.EmployeeId == id && s.Active == true) .Include(s => s.TreatmentAssignment) .ThenInclude(s => s.Employee) .ThenInclude(s => s.User) .Include(s => s.TreatmentAssignment) .ThenInclude(s => s.Treatment) .OrderBy(s => s.Date) .ToListAsync(); //Employee employee = Employee.Employees.Where( // e => e.Id == id.Value).Single(); //Employee.Enrollments = employee.TreatmentAssignments.Select( // s => s.Enrollment); } }
// GET: Employee public ActionResult Index(int?id, string searchString, string sortOrder, string currentFilter, int?page, int?pageSize) { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date"; ViewBag.FNameSortParm = sortOrder == "FName" ? "FName_desc" : "FName"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var employees = from s in db.Employees.Include(e => e.EmployeeStatus.Select(c => c.HeritageCompany)) .Include(e => e.EmployeeStatus.Select(c => c.LegalCompany)) .Include(e => e.EmployeeStatus.Select(c => c.EmployeeStatus)) .Include(e => e.EmployeeStatus.Select(c => c.EmployeeType)) .Include(e => e.EmployeeStatus.Select(c => c.OverTimeStatus)) .Include(e => e.EmployeeStatus.Select(c => c.UnionStatus)) .Include(e => e.Compensations.Select(c => c.CompensationType)) .Include(e => e.Compensations.Select(c => c.Currency)) .Include(e => e.Careers.Select(c => c.Department)) .Include(e => e.Careers.Select(c => c.BudgetArea)) .Include(e => e.Benefits.Select(c => c.BenefitType)) .Include(e => e.Trainings.Select(c => c.TrainingType)) .Include(e => e.Trainings.Select(c => c.TrainingCategory)) .Include(e => e.ParkingAccesses.Select(c => c.Parking)) .Include(e => e.BuildingAccesses.Select(c => c.Building)) .OrderBy(i => i.LastName) select s; if (!String.IsNullOrEmpty(searchString)) { id = null; employees = employees.Where(s => s.LastName.ToUpper().Contains(searchString.ToUpper()) || s.FirstName.ToUpper().Contains(searchString.ToUpper())); } switch (sortOrder) { case "name_desc": employees = employees.OrderByDescending(s => s.LastName); break; case "Date": employees = employees.OrderBy(s => s.HireDate); break; case "date_desc": employees = employees.OrderByDescending(s => s.HireDate); break; case "FName_desc": employees = employees.OrderByDescending(s => s.FirstName); break; case "FName": employees = employees.OrderBy(s => s.FirstName); break; default: employees = employees.OrderBy(s => s.LastName); break; } GlobalVars._pageSize_ = pageSize ?? GlobalVars._pageSize_; int pageNumber = (page ?? 1); var viewModel = new EmployeeIndexData { Employees = employees.ToPagedList(pageNumber, GlobalVars._pageSize_) }; if (!id.Equals(null)) { ViewBag.EmployeeID = id.Value; viewModel.Status = employees.Where( i => i.EmployeeID == id.Value).Single().EmployeeStatus; viewModel.Compensations = employees.Where( i => i.EmployeeID == id.Value).Single().Compensations; viewModel.Careers = employees.Where( i => i.EmployeeID == id.Value).Single().Careers; viewModel.Benefits = employees.Where( i => i.EmployeeID == id.Value).Single().Benefits; viewModel.Trainings = employees.Where( i => i.EmployeeID == id.Value).Single().Trainings; viewModel.ParkingAccesses = employees.Where( i => i.EmployeeID == id.Value).Single().ParkingAccesses; viewModel.BuildingAccesses = employees.Where( i => i.EmployeeID == id.Value).Single().BuildingAccesses; } return(View(viewModel)); }