private TimesheetEditModel GetTimsheet(int year, int month) { int yearmonthCode = int.Parse(year + "" + month.ToString().PadLeft(2, '0')); var timesheet = new TimesheetEditModel { Date = new DateTime(year, month, 1), ProjectTrakers = (from p in _projectTrackerService.All.Include(item => item.Project).Include(item => item.Tracker) from e in _employeeCurrentProjectService.All where p.Project_Code == e.Project_Code && e.Employee_Code == EmployeeCode select p).ToList(), WorkDates = _workDateService.FindBy(item => item.YYYYMM_Code == yearmonthCode).ToList(), TimeCards = (from e in _employeeCurrentProjectService.All from a in _assignmentService.All from t in _timeCardService.All where a.Employee_Code == e.Employee_Code && t.Assignment_Id == a.Id && e.Employee.Code == EmployeeCode && a.ProjectTracker.Project_Code == e.Project_Code && t.WorkDate.YYYYMM_Code == yearmonthCode select t).ToList(), Locked = _yyyymmLockedService.All.Any(item => item.Code >= yearmonthCode) }; //if(timesheet.WorkDates.Count==0) // for (var i = 1; i <= DateTime.DaysInMonth(year,month); i++) // { // timesheet.WorkDates.Add(new Models.WorkDate { // Day_of_Month = i, // Id_Date=new DateTime(year,month,i), // YYYYMM_Code= yearmonthCode // }); // } //var context = new PrincipalContext(ContextType.Domain, "ldap://localhost:63083/dc=maxcrc,dc=com"); //var user = UserPrincipal.FindByIdentity(context, User.Identity.Name); //WindowsIdentity clientId = (WindowsIdentity)User.Identity; //using (var context = new PrincipalContext(ContextType.Domain, "DCESTAGIO")) //{ // var principal = UserPrincipal.FindByIdentity(context, User.Identity.Name); // var firstName = principal.GivenName; // var lastName = principal.Surname; //} return(timesheet); }
private TimesheetEditModel GetTimsheet(int year, int month) { int yearmonthCode = int.Parse(year + "" + month.ToString().PadLeft(2, '0')); var timesheet = new TimesheetEditModel { EmployeeCode = EmployeeCode, Date = new DateTime(year, month, 1), ProjectTrakers = (from p in _projectTrackerService.All.Include(item => item.Project).Include(item => item.Tracker) from e in _employeeCurrentProjectService.All where (p.Project_Code == e.Project_Code && e.Employee_Code == EmployeeCode) || p.Project_Code == "NCHG" select p).Distinct().ToList(), WorkDates = _workDateService.FindBy(item => item.YYYYMM_Code == yearmonthCode).ToList(), TimeCards = (from e in _employeeCurrentProjectService.All from p in _projectTrackerService.All from a in _assignmentService.All from t in _timeCardService.All where (a.Employee_Code == e.Employee_Code && t.Assignment_Id == a.Id && e.Employee_Code == EmployeeCode && a.ProjectTracker.Project_Code == e.Project_Code && t.WorkDate.YYYYMM_Code == yearmonthCode) || (p.Project_Code == "NCHG" && a.Project_Tracker_Id == p.Id && t.Assignment_Id == a.Id && a.Employee_Code == EmployeeCode) select t).Distinct().ToList(), Assignments = _assignmentService.FindBy(item => item.Employee_Code == EmployeeCode).ToList(), Locked = _yyyymmLockedService.All.Any(item => item.Code >= yearmonthCode) }; //if(timesheet.WorkDates.Count==0) // for (var i = 1; i <= DateTime.DaysInMonth(year,month); i++) // { // timesheet.WorkDates.Add(new Models.WorkDate { // Day_of_Month = i, // Id_Date=new DateTime(year,month,i), // YYYYMM_Code= yearmonthCode // }); // } return(timesheet); }