protected ProjectNetflixContributor CreateNetflixProjectContributor(NotificationPartner partner) { int totalEffort = 0; var potentielDaysOfWork = 0; DateTime latestDate = DateTime.Today; DateTime StartDate = DateTime.Today; var employee = (from p in _context.Employe where p.Id == partner.EmployeId select p).First(); //var tasks = (from p in _context.TaskOwner // join t in _context.Task on p.TaskId equals t.Id // where p.EmployeId == partner.EmployeId // select new { taskOwner = p, task = t }).ToList(); //foreach (var task in tasks) //{ // if (task.task.Status != "Completed") // { // totalEffort = totalEffort + task.task.EstEffort; // if (latestDate < task.task.EstEnd) // { // latestDate = task.task.EstEnd; // } // } //} //while (StartDate <= latestDate) //{ // if (StartDate.DayOfWeek != DayOfWeek.Saturday && StartDate.DayOfWeek != DayOfWeek.Sunday) // { // ++potentielDaysOfWork; // } // StartDate = StartDate.AddDays(1); //} //var availableTimeForProjects = potentielDaysOfWork * (employee.Workload / 5) * employee.ProjectWorkRatio / 100; //var occupancyRate = totalEffort / availableTimeForProjects * 100; ProjectNetflixContributor contributor_netflix = new ProjectNetflixContributor() { Id = partner.Id, Department = employee.Department, Name = employee.Name, EmployeeId = employee.IdSAP, Picture = employee.Picture, Title = employee.Title, OccupancyRate = 0 }; return(contributor_netflix); }
public IEnumerable <Models.ProjectNetflixContributor> GetProjectContributor(long id) { List <ProjectNetflixContributor> projectContributor = new List <ProjectNetflixContributor>(); List <Notification> projectNotifications = getProjectNotifications(id); List <NotificationPartner> partners = getAllPartnersFromNotifications(projectNotifications); foreach (NotificationPartner partner in partners) { ProjectNetflixContributor contributor_netflix = CreateNetflixProjectContributor(partner); projectContributor.Add(contributor_netflix); } return(projectContributor); }