public ActionResult EmployeeduMois() { var ListNonAttendance = new List <non_attendance>(); var ListNonAttendanceDomain = non_attendanceService.GetMany(); var ListEmployee = new List <user>(); var listEmployeeDomain = employeeService.GetMany(); foreach (non_attendance r in ListNonAttendanceDomain) { ListNonAttendance.Add(new non_attendance() { Id = r.Id, Date = r.Date, employe_Id = r.employe_Id, Isjustified = r.Isjustified }); } foreach (user r in listEmployeeDomain) { ListEmployee.Add(new user() { id = r.id, first_name = r.first_name, last_name = r.last_name, mail_address = r.mail_address, phone_number = r.phone_number, path_image = r.path_image }); } ViewBag.employee = ListEmployee; List <int> repartitions = new List <int>(); List <non_attendance> list1 = ListNonAttendance; List <user> list2 = ListEmployee; var todayMotnh = DateTime.Today.Month; var ages = list1.OrderBy(x => x.Id).Where(x => ((DateTime)x.Date).Month == todayMotnh).Select(x => x.employe_Id).Distinct(); //[7,7,5,2] var names = list2.Select(x => x.first_name).Distinct(); foreach (var item in ages) { repartitions.Add(10 - list1.Count(x => x.employe_Id == item)); } var rep = repartitions; ViewBag.AGES = ages; foreach (var r0 in list2) { foreach (var r in ViewBag.AGES) { ages2 = list2.Select(x => x.first_name); } } ViewBag.AGES2 = ages2; ViewBag.REP = repartitions.ToList(); return(View()); }
public void em2() { var ListNonAttendance = new List <non_attendance>(); var ListNonAttendanceDomain = non_attendanceService.GetMany(); var ListEmployee2 = new List <user>(); var listEmployeeDomain2 = employeeService.GetMany(); foreach (non_attendance r in ListNonAttendanceDomain) { ListNonAttendance.Add(new non_attendance() { Id = r.Id, Date = r.Date, employe_Id = r.employe_Id, Isjustified = r.Isjustified }); } foreach (user r in listEmployeeDomain2) { ListEmployee2.Add(new user() { id = r.id, first_name = r.first_name, last_name = r.last_name, mail_address = r.mail_address, phone_number = r.phone_number, path_image = r.path_image }); } ViewBag.employee2 = ListEmployee2; List <int> repartitionList = new List <int>(); List <non_attendance> ListNonAttendance_M = ListNonAttendance; List <user> ListEmployee_M = ListEmployee2; var todayMotnh = DateTime.Today.Month; var countHeures = ListNonAttendance_M.Where(x => ((DateTime)x.Date).Month == todayMotnh).Select(x => x.employe_Id).Distinct(); //[7,7,5,2] var selectNameEmployee = ListEmployee_M.Select(x => x.first_name).Distinct(); foreach (var item in countHeures) { repartitionList.Add(10 - ListNonAttendance_M.Count(x => x.employe_Id == item)); } ViewBag.countHeures2 = countHeures; foreach (var r0 in ListEmployee_M) { foreach (var r in ViewBag.countHeures2) { if (r == r0.id) { count2 = ListEmployee_M.Select(x => x.first_name); } } } ViewBag.countHeuresFinal = count2; ViewBag.REPName = repartitionList.ToList(); }