public HttpResponseMessage GetClaimBenefitsDefaultDates(int ClaimID) { HttpResponseMessage message = new HttpResponseMessage(); if (context.Claims.SingleOrDefault(i => i.ClaimID == ClaimID) == null) { return(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("Claim does not exist") }); } try { var bd = context.GetClaimBenefitsDefaultDates(ClaimID).First(); DateTime ReferralDate = bd.ReferralDate ?? DateTime.Now; int WaitPeriod = bd.STDWaitPeriodDays ?? 0; int LTDDuration = bd.LTDDurationWeeks ?? 0; DateTime STDStartDate = ReferralDate.AddDays(WaitPeriod); DateTime STDEndDate = STDStartDate.AddDays(LTDDuration * 7); DateTime LTDStartDate = STDEndDate.AddDays(1); DefaultBenefitDatesDTO benefitDates = new DefaultBenefitDatesDTO { STDStartDate = STDStartDate.ToString("yyyy-MM-dd"), LTDStartDate = LTDStartDate.ToString("yyyy-MM-dd"), STDEndDate = STDEndDate.ToString("yyyy-MM-dd") }; message.StatusCode = HttpStatusCode.OK; message.Content = new StringContent(JsonConvert.SerializeObject(benefitDates), Encoding.UTF8, "application/json"); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); //ELMAH Signaling, this will log the catched exception to elmah.axd return(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(e.Message) }); } return(message); }