예제 #1
0
 public HttpResponseMessage GetWeekelySummaryOfEmpDetails(GetDSRDomainModel model)
 {
     try
     {
         HttpResponseMessage httpResponse = new HttpResponseMessage();
         if (model != null)
         {
             var dsrs = EmployeeRepository.GetWeekelySummaryOfEmpDetails(model);
             if (dsrs == null)
             {
                 httpResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error Occurred");
             }
             else
             {
                 httpResponse = Request.CreateResponse(HttpStatusCode.OK, dsrs);
             }
         }
         else
         {
             httpResponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Found");
         }
         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
         });
     }
 }
예제 #2
0
        public HttpResponseMessage GetSummaryOfWeekDetails(GetDSRDomainModel model)
        {
            try
            {
                HttpResponseMessage httpResponse = new HttpResponseMessage();
                if (model != null)
                {
                    var dsrs = EmployeeRepository.GetSummaryOfWeekDetails(model);
                    if (dsrs == null)
                    {
                        httpResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error Occurred");
                    }
                    else
                    {
                        httpResponse = Request.CreateResponse(HttpStatusCode.OK, dsrs);
                    }
                    //else if (dsrs.Count() == 0)
                    //{
                    //    httpResponse = Request.CreateResponse(HttpStatusCode.OK, SummaryModel);
                    //}
                    //else
                    //{
                    //    SummaryModel = new SummaryDSRDomainModel();

                    //    Parallel.ForEach(dsrs, d =>
                    //    {
                    //        var mins = ConversionInMinute(d.WorkingHoursOfProject);
                    //        var finalmins = ConversionInMinute(TotalWorkingHoursOfProject.ToString());
                    //        var overAllMins = mins + finalmins;
                    //        var finalhrs = ConversionInHour(overAllMins);
                    //        TotalWorkingHoursOfProject = finalhrs;

                    //        var overAllWorkingHoursMins = ConversionInMinute(d.TotalWorkingHoursOfProject);
                    //        var overAllWorkingHourfinalmins = ConversionInMinute(OverAllTotalWorkingHoursOfProject.ToString());
                    //        var overAllWorkingHourMins = overAllWorkingHoursMins + overAllWorkingHourfinalmins;
                    //        OverAllTotalWorkingHoursOfProject = ConversionInHour(overAllWorkingHourMins);
                    //    });
                    //    SummaryModel.dsr = dsrs;
                    //    SummaryModel.OverallTotalWorkingHours = TotalWorkingHoursOfProject;
                    //    SummaryModel.OverallWeekTotalWorkingHours = OverAllTotalWorkingHoursOfProject;
                    //    httpResponse = Request.CreateResponse(HttpStatusCode.OK, SummaryModel);
                    //}
                }
                else
                {
                    httpResponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Found");
                }
                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
                });
            }
        }
 public List <GetWeeklyEmployeeDSRDomainModel> GetSummaryOfWeekDetails(GetDSRDomainModel model)
 {
     try
     {
         var       StartDate = DateTime.ParseExact(model.startdate, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
         var       EndDate   = DateTime.ParseExact(model.enddate, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
         SqlHelper objHelper = new SqlHelper();
         var       summaries = objHelper.Query <GetWeeklyEmployeeDSRDomainModel>("GetSummaryOfWeekDetails", new { startdate = Convert.ToDateTime(StartDate), enddate = Convert.ToDateTime(EndDate) }).ToList();
         return(summaries);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }