public DTO.DetailFormData GetDetail(int year, int userId, out Library.DTO.Notification notification) { DTO.DetailFormData data = new DTO.DetailFormData(); data.DetailByPersons = new List <DTO.DetailByPerson>(); data.PlaningByPersons = new List <DTO.PlaningByPerson>(); data.ResolvedRequestByPersons = new List <DTO.ResolvedRequestByPerson>(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success, Message = string.Empty }; try { using (DevRequestOverviewRptEntities context = CreateContext()) { data.DetailByPersons = converter.DB2DTO_DetailByPerson(context.DevRequestOverviewRpt_function_getDetailByPerson(year, userId).ToList()); data.PlaningByPersons = converter.DB2DTO_PlaningByPerson(context.DevRequestOverviewRpt_function_getPlaningByPerson(year, userId).ToList()); data.ResolvedRequestByPersons = converter.DB2DTO_ResolvedRequestByPerson(context.DevRequestOverviewRpt_function_getResolvedRequestByPerson(year, userId).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } if (data.PlaningByPersons.Count() > 0) { DateTime currentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 10, 0, 0); // fill in start date and end date foreach (DTO.PlaningByPerson dtoPlaning in data.PlaningByPersons) { dtoPlaning.start_string = currentDate.ToString("dd-MM-yyyy HH:mm"); if (dtoPlaning.EstWorkingHour > 8) { currentDate = currentDate.AddDays(dtoPlaning.EstWorkingHour.Value / 8); dtoPlaning.end_string = currentDate.ToString("dd-MM-yyyy HH:mm"); } else { dtoPlaning.end_string = dtoPlaning.start_string; } currentDate = currentDate.AddDays(1); } } return(data); }
// // CUSTOM FUNCTION // public DTO.ReportFormData GetOverview(int year, out Library.DTO.Notification notification) { DTO.ReportFormData data = new DTO.ReportFormData(); data.Overviews = new List <DTO.Overview>(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success, Message = string.Empty }; try { using (DevRequestOverviewRptEntities context = CreateContext()) { data.Overviews = converter.DB2DTO_Overview(context.DevRequestOverviewRpt_function_getOverview(year).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }