public ActionResult PartialReportByDepartment(string departmentId, DateTime?dateValue) { if (departmentId == "") { return(PartialView()); } IEnumerable <Employee> employees = unit.Employees .GetEmployeesByDepartmentId(Guid.Parse(departmentId), dateValue); var empList = new List <ReportByCompanyViewModel>(); ReportByCompanyViewModel model; foreach (var item in employees) { model = new ReportByCompanyViewModel { EmployeeId = item.EmployeeId, EmployeeName = item.EFullName, Position = item.Position.Name, AverageMark = item.TaskLists.Select(t => t.AverageMark).Average() }; empList.Add(model); } return(PartialView(empList)); }
public ActionResult PartialReportByCompany(DateTime?dateValue) { IEnumerable <Employee> employees = unit.Employees.GetEmployeesByTaskDate(dateValue); var employeeList = new List <ReportByCompanyViewModel>(); ReportByCompanyViewModel model; foreach (Employee employee in employees) { model = new ReportByCompanyViewModel { EmployeeId = employee.EmployeeId, EmployeeName = employee.EFullName, Department = employee.Department.Name, Position = employee.Position.Name, AdoptionDate = employee.AdoptionDate, AverageMark = employee.TaskLists.Select(t => t.AverageMark).Average() }; employeeList.Add(model); } ViewBag.Today = DateTime.Now.ToString("yyyy-MM"); return(PartialView(employeeList)); }
public ActionResult ReportByDepartment(string departmentId, DateTime?dateValue) { IEnumerable <Employee> emplist = unit.Employees.GetEmployeesWithRelations(); ViewBag.Today = DateTime.Now.ToString("yyyy-MM"); if (User.IsInRole("admin")) { ViewBag.Departments = new SelectList( unit.Departments.GetAll(), "DepartmentId", "Name" ); if (departmentId != null) { var employeeList = new List <ReportByCompanyViewModel>(); ReportByCompanyViewModel model; foreach (Employee employee in emplist) { model = new ReportByCompanyViewModel { EmployeeId = employee.EmployeeId, EmployeeName = employee.EFullName, Position = employee.Position.Name, AverageMark = employee.TaskLists.Select(t => t.AverageMark).Average() }; employeeList.Add(model); } return(View(employeeList)); } return(View()); } else { ViewBag.Departments = new SelectList( unit.Departments.GetAvailableDepartments(User.Identity.GetUserId()), "DepartmentId", "Name" ); if (departmentId != null) { var employeeList = new List <ReportByCompanyViewModel>(); ReportByCompanyViewModel model; foreach (Employee employee in emplist) { model = new ReportByCompanyViewModel { EmployeeId = employee.EmployeeId, EmployeeName = employee.EFullName, Position = employee.Position.Name, AverageMark = employee.TaskLists.Select(t => t.AverageMark).Average() }; employeeList.Add(model); } return(View(employeeList)); } return(View()); } }