public List <SummaryOfWeekDetailsMainDomainModel> SummaryOfWeekDetailsMain(GetSummaryDomainModel model) { try { SqlHelper objHelper = new SqlHelper(); var summaries = objHelper.Query <SummaryOfWeekDetailsMainDomainModel>("GET_SUMMARY_OF_WEEK_DETAILS_MAIN", new { startday = model.startday, endday = model.endday }).ToList(); if (summaries.Count() > 0 && summaries != null) { var GetDistinctProjects = summaries.GroupBy(x => x.ProjectId).Select(g => new { ProjectId = g.Key }).ToList(); //get subdetails for each summary foreach (var item in GetDistinctProjects) { var summary = objHelper.Query <SummaryOfWeekSubDetailsMainDomainModel>("GET_SUMMARY_OF_WEEK_SUBDETAILS", new { projectId = item.ProjectId, startday = model.startday, endday = model.endday }).ToList(); var GetProject = summaries.First(x => x.ProjectId == item.ProjectId); GetProject.subweeksummary = summary; } } return(summaries); } catch (Exception ex) { return(null); } }
public List <SummaryOfWeekSubDetailsMainDomainModel> SummaryOfWeekSubDetails(long ProjectId, GetSummaryDomainModel model) { var summary = objHelper.Query <SummaryOfWeekSubDetailsMainDomainModel>("GET_SUMMARY_OF_WEEK_SUBDETAILS", new { projectId = ProjectId, startday = model.startday, endday = model.endday }).ToList(); return(summary); }
public HttpResponseMessage SummaryOfWeekDetails(GetSummaryDomainModel model) { decimal hours, finalHours = 0; OverAllSummaryOfWeekDetailsMainDomainModel OverAllSummaryOfWeekDetailsModel = new OverAllSummaryOfWeekDetailsMainDomainModel(); List <SummaryOfWeekDetailsMainDomainModel> SummaryOfWeekDetailsMainModelList = new List <SummaryOfWeekDetailsMainDomainModel>(); try { HttpResponseMessage httpResponse = new HttpResponseMessage(); if (model != null) { var Summary = EmployeeRepository.SummaryOfWeekDetailsMain(model); if (Summary != null) { var GroupedSummaries = Summary.GroupBy(x => x.ProjectId); foreach (var items in GroupedSummaries) { finalHours = 0; // reset for every project else hours will be added to next project hours = 0; // reset for every project else hours will be added to next project foreach (var project in items) { // to get accurate hours var mins = ConversionInMinute(project.WorkingHours.ToString()); hours += ConversionInHour(mins); // converted again for final output var finalMins = ConversionInMinute(hours.ToString()); finalHours = ConversionInHour(finalMins); } var Getproject = items.First(); var SummaryOfWeekDetailsMainDomainModel = new SummaryOfWeekDetailsMainDomainModel() { ProjectId = Getproject.ProjectId, WorkingHours = finalHours, ClientName = Getproject.ClientName, ProjectTitle = Getproject.ProjectTitle }; SummaryOfWeekDetailsMainModelList.Add(SummaryOfWeekDetailsMainDomainModel); var GetProjectFromSummary = SummaryOfWeekDetailsMainModelList.First(x => x.ProjectId == Getproject.ProjectId); // to get subsummary of every department for every project GetProjectFromSummary.subweeksummary = Getproject.subweeksummary; } if (Summary.Count() > 0) { foreach (var item in SummaryOfWeekDetailsMainModelList) { var DotNetHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "Dot Net"); if (DotNetHours != null) { var mins = ConversionInMinute(DotNetHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalDotNetWorkingHours += hrs; var finalmins = ConversionInMinute(TotalDotNetWorkingHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalDotNetWorkingHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } var PhpHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "Php"); if (PhpHours != null) { var mins = ConversionInMinute(PhpHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalPhpWorkingHours += hrs; var finalmins = ConversionInMinute(TotalPhpWorkingHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalPhpWorkingHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } var AndroidHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "Android"); if (AndroidHours != null) { var mins = ConversionInMinute(AndroidHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalAndroidWorkingHours += hrs; var finalmins = ConversionInMinute(TotalAndroidWorkingHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalAndroidWorkingHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } var IOSHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "IPhone"); if (IOSHours != null) { var mins = ConversionInMinute(IOSHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalIOSWorkingHours += hrs; var finalmins = ConversionInMinute(TotalIOSWorkingHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalIOSWorkingHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } var DesignHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "Design"); if (DesignHours != null) { var mins = ConversionInMinute(DesignHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalDesignWorkingHours += hrs; var finalmins = ConversionInMinute(TotalDesignWorkingHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalDesignWorkingHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } var SEOHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "SEO"); if (SEOHours != null) { var mins = ConversionInMinute(SEOHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalSeoWorkingHours += hrs; var finalmins = ConversionInMinute(TotalSeoWorkingHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalSeoWorkingHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } var QAHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "QA"); if (QAHours != null) { var mins = ConversionInMinute(QAHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalQaWorkingHours += hrs; var finalmins = ConversionInMinute(TotalQaWorkingHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalQaWorkingHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } var HybridHours = item.subweeksummary.FirstOrDefault(x => x.DepartmentName == "Hybrid App "); if (HybridHours != null) { var mins = ConversionInMinute(HybridHours.WorkingHours.ToString()); var hrs = ConversionInHour(mins); TotalHybridHours += hrs; var finalmins = ConversionInMinute(TotalHybridHours.ToString()); var finalhrs = ConversionInHour(finalmins); TotalHybridHours = finalhrs; //var TotalWeeklyHoursMins = ConversionInMinute(TotalWeeklyHours.ToString()) + finalmins; //TotalWeeklyHours = ConversionInHour(TotalWeeklyHoursMins); } } OverAllSummaryOfWeekDetailsModel.TotalDotNetWorkingHours = TotalDotNetWorkingHours; OverAllSummaryOfWeekDetailsModel.TotalPhpWorkingHours = TotalPhpWorkingHours; OverAllSummaryOfWeekDetailsModel.TotalAndroidWorkingHours = TotalAndroidWorkingHours; OverAllSummaryOfWeekDetailsModel.TotalIOSWorkingHours = TotalIOSWorkingHours; OverAllSummaryOfWeekDetailsModel.TotalDesignWorkingHours = TotalDesignWorkingHours; OverAllSummaryOfWeekDetailsModel.TotalSeoWorkingHours = TotalSeoWorkingHours; OverAllSummaryOfWeekDetailsModel.TotalQaWorkingHours = TotalQaWorkingHours; OverAllSummaryOfWeekDetailsModel.TotalHybridWorkingHours = TotalHybridHours; var weeklyMinsTotal = ConversionInMinute(TotalDotNetWorkingHours.ToString()) + ConversionInMinute(TotalPhpWorkingHours.ToString()) + ConversionInMinute(TotalAndroidWorkingHours.ToString()) + ConversionInMinute(TotalIOSWorkingHours.ToString()) + ConversionInMinute(TotalDesignWorkingHours.ToString()) + ConversionInMinute(TotalSeoWorkingHours.ToString()) + ConversionInMinute(TotalQaWorkingHours.ToString()) + ConversionInMinute(TotalHybridHours.ToString()); OverAllSummaryOfWeekDetailsModel.TotalWeeklyWorkingHours = ConversionInHour(weeklyMinsTotal); OverAllSummaryOfWeekDetailsModel.SummaryOfWeekDetails = SummaryOfWeekDetailsMainModelList; } httpResponse = Request.CreateResponse(HttpStatusCode.OK, OverAllSummaryOfWeekDetailsModel); } else { httpResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error occurred"); } } else { httpResponse = Request.CreateResponse(HttpStatusCode.Unauthorized, "Not authorized"); } return(httpResponse); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "An error occurred, please try again or contact the administrator.", StatusCode = HttpStatusCode.InternalServerError }); } }