public IQueryable <MHMCommonBenefitsMst> GetMHMCommonBenefitsMsts() { using (var DB = new MHMDal.Models.MHM()) { return(DB.MHMCommonBenefitsMsts); } }
//protected override void Dispose(bool disposing) //{ // if (disposing) // { // DB.Dispose(); // } // base.Dispose(disposing); //} private bool MHMCommonBenefitsMstExists(long id) { using (var DB = new MHMDal.Models.MHM()) { return(DB.MHMCommonBenefitsMsts.Count(e => e.MHMBenefitID == id) > 0); } }
public HttpResponseMessage GetData() { MHMDal.Models.MHM DB = new MHMDal.Models.MHM(); var test = DB.Cases.Take(5).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, test)); }
private bool UpdateCaseResults(long CaseID, List <CasePlanResult> lstCasePlanResult) { using (var DB = new MHMDal.Models.MHM()) { using (var dbContextTransaction = DB.Database.BeginTransaction()) { try { //Remove CasePlanResult var CasePlanResult = DB.CasePlanResults.Where(r => r.CaseId == CaseID).ToList(); DB.CasePlanResults.RemoveRange(CasePlanResult); DB.SaveChanges(); var CasePlanResults = lstCasePlanResult.ToList(); // Save Case Result foreach (var r in CasePlanResults) { DB.Entry(r).State = EntityState.Detached; r.CaseId = CaseID; r.GrossAnnualPremium = r.GrossAnnualPremium; r.FederalSubsidy = r.FederalSubsidy; r.NetAnnualPremium = r.NetAnnualPremium; r.MonthlyPremium = r.MonthlyPremium; r.Copays = r.Copays; r.PaymentsToDeductibleLimit = r.PaymentsToDeductibleLimit; r.CoinsuranceToOutOfPocketLimit = r.CoinsuranceToOutOfPocketLimit; r.ContributedToYourHSAAccount = r.ContributedToYourHSAAccount; r.TaxSavingFromHSAAccount = r.TaxSavingFromHSAAccount; r.Medical = r.Medical; r.TotalPaid = r.TotalPaid; r.PaymentsByInsuranceCo = r.PaymentsByInsuranceCo; r.DeductibleSingle = r.DeductibleSingle; r.DeductibleFamilyPerPerson = r.DeductibleFamilyPerPerson; r.DeductibleFamilyPerGroup = r.DeductibleFamilyPerGroup; r.OPLSingle = r.OPLSingle; r.OPLFamilyPerPerson = r.OPLFamilyPerPerson; r.OPLFamilyPerGroup = r.OPLFamilyPerGroup; r.Coinsurance = r.Coinsurance; r.WorstCase = r.WorstCase; r.CreatedDateTime = DateTime.Now; DB.CasePlanResults.Add(r); DB.SaveChanges(); } dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } } }
public HttpResponseMessage AddEmployer(EmployerMst employermst) { Response oResponse = new Response(); if (!ModelState.IsValid) { string messages = string.Join(Environment.NewLine, ModelState.Values .SelectMany(r => r.Errors) .Select(r => r.ErrorMessage)); oResponse.Status = false; oResponse.Message = messages; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } using (var DB = new MHMDal.Models.MHM()) { try { HttpResponseMessage response; if (DB.EmployerMsts.Any(r => r.EmployerId == employermst.EmployerId)) { oResponse.Status = false; oResponse.Message = "Employer Id already exist"; response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } employermst.CreatedDateTime = System.DateTime.Now; DB.EmployerMsts.Add(employermst); DB.SaveChanges(); oResponse.Status = true; oResponse.Message = "Success"; response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.InnerException.Message; string ExceptionString = "Api : AddEmployer" + Environment.NewLine; ExceptionString += "Request : " + " employermst " + JsonConvert.SerializeObject(employermst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "AddEmployer - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
public void UpdateCaseToSent(long CaseId, bool MailStatus, long ModifiedBy) { using (var DB = new MHMDal.Models.MHM()) { var oCase = DB.Cases.Where(r => r.CaseID == CaseId).FirstOrDefault(); try { if (oCase.StatusId == 6 || oCase.StatusId == 8) { oCase.StatusId = MailStatus ? 8 : oCase.StatusId; } else { oCase.StatusId = MailStatus ? 2 : oCase.StatusId; } oCase.CaseJobRunStatus = MailStatus ? Convert.ToString(MHM.Api.Models.EnumStatusModel.CaseJobRunStatus.ReportSent) : Convert.ToString(MHM.Api.Models.EnumStatusModel.CaseJobRunStatus.SendError); oCase.CaseJobRunDt = DateTime.Now; oCase.CaseJobRunUserID = ModifiedBy; DB.SaveChanges(); var Job = DB.JobMasters.Where(r => r.JobNumber == oCase.JobNumber).FirstOrDefault(); Job.LastJobRunDt = DateTime.Now; Job.LastJubRunUserID = ModifiedBy; Job.LastJobRunStatus = Job.JobRunStatus; if (Job.JobRunStatus != Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.GenErrors) && Job.JobRunStatus != Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.SendErrors)) { Job.JobRunStatus = MailStatus ? Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.AllSent) : Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.SendErrors); } DB.SaveChanges(); } catch (Exception ex) { oCase.CaseJobRunStatus = Convert.ToString(MHM.Api.Models.EnumStatusModel.CaseJobRunStatus.SendError); oCase.CaseJobRunMsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; oCase.CaseJobRunDt = DateTime.Now; oCase.CaseJobRunUserID = ModifiedBy; DB.SaveChanges(); var Job = DB.JobMasters.Where(r => r.JobNumber == oCase.JobNumber).FirstOrDefault(); Job.LastJobRunDt = DateTime.Now; Job.LastJubRunUserID = ModifiedBy; Job.LastJobRunStatus = Job.JobRunStatus; if (Job.JobRunStatus != Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.GenErrors) && Job.JobRunStatus != Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.SendErrors)) { Job.JobRunStatus = Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.SendErrors); } DB.SaveChanges(); } } }
//[Authorize] public CarrierViewModel Carrier() { CarrierViewModel oCarrierViewModel = new CarrierViewModel(); List <IssuerMst> oModellst = new List <IssuerMst>(); try { using (var DB = new MHMDal.Models.MHM()) { //BenefitIdsViewModel class inside the IssuerMst class List <BenefitIdsViewModel> lstIssuerBenefitIds = DB.Database.SqlQuery <BenefitIdsViewModel>("exec sp_GetBenefitId").ToList <BenefitIdsViewModel>(); var result = DB.IssuerMsts.Where(r => r.Status == true).ToList(); foreach (var item in result) { oModellst.Add(new IssuerMst { Id = item.Id, IssuerCode = item.IssuerCode, IssuerName = item.IssuerName + " (" + item.IssuerCode + ")", Abbreviations = item.Abbreviations, BenefitIds = lstIssuerBenefitIds.Where(r => r.CarrierId == item.Id).ToList() }); } oCarrierViewModel.Carriers = oModellst; if (oCarrierViewModel.Carriers.Count > 0) { oCarrierViewModel.Status = true; oCarrierViewModel.Message = "Success"; } else { oCarrierViewModel.Status = true; oCarrierViewModel.Message = "Carrier does not exist."; } } } catch (Exception ex) { oCarrierViewModel.Status = false; oCarrierViewModel.Message = ex.Message; string ExceptionString = "Api : Carrier" + Environment.NewLine; ExceptionString += "Request : " + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oCarrierViewModel) + Environment.NewLine; var fileName = "Carrier - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); } return(oCarrierViewModel); }
public HttpResponseMessage GetMHMCommonBenefitsMst(long id) { Dictionary <string, object> data = new Dictionary <string, object>(); Response oResponse = new Response(); try { using (var DB = new MHMDal.Models.MHM()) { MHMCommonBenefitsMst mHMCommonBenefitsMst = DB.MHMCommonBenefitsMsts.Find(id); mHMCommonBenefitsMst.MHMBenefitMappingMsts = mHMCommonBenefitsMst.MHMBenefitMappingMsts; if (mHMCommonBenefitsMst == null) { data.Add("Status", false); data.Add("Message", "Benefit cannot be found. "); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } else { data.Add("Status", true); data.Add("Message", "Success"); data.Add("MHMCommonBenefit", mHMCommonBenefitsMst); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } } } catch (Exception ex) { data.Add("Status", false); data.Add("Message", ex.Message); string ExceptionString = "Api : GetMHMCommonBenefitsMst" + Environment.NewLine; ExceptionString += "Request : " + " id " + id + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetMHMCommonBenefitsMst - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, data); return(response); } }
public HttpResponseMessage GetRatingAreas(string StateCode) { Response oResponse = new Response(); Dictionary <string, object> res = new Dictionary <string, object>(); try { using (var DB = new MHMDal.Models.MHM()) { List <long> lst = DB.tblRatingAreas.Where(r => r.StateCode == StateCode).Select(r => r.RatingAreaID).Distinct().ToList(); var lstRatingAreas = DB.tblRatingAreaMsts.Where(t => lst.Contains(t.RatingAreaID)).Select(r => new { r.RatingAreaID, r.RatingAreaName }).Distinct().ToList(); if (lstRatingAreas.Count > 0) { res.Add("Status", "true"); res.Add("Message", "Success"); res.Add("RatingAreas", lstRatingAreas); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } else { res.Add("Status", "false"); res.Add("Message", "RatingAreas does not exist."); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : GetRatingAreas" + Environment.NewLine; ExceptionString += "Request : " + " StateCode " + StateCode + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetRatingAreas - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } }
public HttpResponseMessage GetEntityTypes() { Response oResponse = new Response(); Dictionary <string, object> res = new Dictionary <string, object>(); try { using (var DB = new MHMDal.Models.MHM()) { var lstEntityTypes = DB.tblStateAbrevs.Select(r => r.EntityType).Distinct().ToList(); if (lstEntityTypes.Count > 0) { res.Add("Status", "true"); res.Add("Message", "Success"); res.Add("EntityTypes", lstEntityTypes); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } else { res.Add("Status", "false"); res.Add("Message", "EntityTypes does not exist."); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : GetEntityTypes" + Environment.NewLine; ExceptionString += "Request : " + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetEntityTypes - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } }
public HttpResponseMessage GetCarrier(string IssuerCode) { Response oResponse = new Response(); Dictionary <string, object> res = new Dictionary <string, object>(); using (var DB = new MHMDal.Models.MHM()) { try { IssuerMst objIssuer = DB.IssuerMsts.Where(r => r.IssuerCode == IssuerCode).FirstOrDefault(); if (objIssuer != null) { res.Add("Status", true); res.Add("Message", "success"); res.Add("IssuerMaster", objIssuer); HttpResponseMessage objResponse = Request.CreateResponse(HttpStatusCode.OK, res); return(objResponse); } else { res.Add("Status", "failed"); res.Add("Message", "IssuerMaster does not exist"); HttpResponseMessage objResponse = Request.CreateResponse(HttpStatusCode.OK, res); return(objResponse); } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : GetCarrier" + Environment.NewLine; ExceptionString += "Request : " + " IssuerCode " + IssuerCode + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetCarrier - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
public HttpResponseMessage GetEmployer(long EmployerId) { Dictionary <string, object> data = new Dictionary <string, object>(); Response oResponse = new Response(); using (var DB = new MHMDal.Models.MHM()) { try { EmployerMst employermast = DB.EmployerMsts.Find(EmployerId); if (employermast == null) { data.Add("Status", false); data.Add("Message", "Employer cannot be found. "); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } else { data.Add("Status", true); data.Add("Message", "Success"); data.Add("Employer", employermast); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } } catch (Exception ex) { data.Add("Status", false); data.Add("Message", ex.Message); string ExceptionString = "Api : GetEmployer" + Environment.NewLine; ExceptionString += "Request : " + " EmployerId " + EmployerId + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetEmployer - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, data); return(response); } } }
public HttpResponseMessage GetAllStates() { Dictionary <string, object> res = new Dictionary <string, object>(); try { using (var DB = new MHMDal.Models.MHM()) { var States = DB.tblStateAbrevs.ToList(); if (States.Count() > 0) { res.Add("Status", "true"); res.Add("Message", "States List"); res.Add("States", States.Select(r => new { StateID = r.Id, r.StateName, r.StateCode }).OrderBy(r => r.StateName)); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } else { res.Add("Status", "False"); res.Add("Message", "State cannot be found. "); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } } } catch (Exception ex) { res.Add("Status", "False"); res.Add("Message", ex.Message); string ExceptionString = "Api : GetAllStates" + Environment.NewLine; ExceptionString += "Request : " + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(res) + Environment.NewLine; var fileName = "GetAllStates - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, res); return(response); } }
public HttpResponseMessage GetRatingArea() { Dictionary <string, object> data = new Dictionary <string, object>(); try { using (var DB = new MHMDal.Models.MHM()) { var RatingList = DB.tblRatingAreaMsts.ToList(); if (RatingList.Count > 0) { data.Add("Status", true); data.Add("Message", "Success"); data.Add("List", RatingList.Select(r => new { r.RatingAreaID, r.RatingAreaName })); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } else { data.Add("Status", true); data.Add("Message", "Rating Area cannot be found. "); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } } } catch (Exception ex) { data.Add("Status", false); data.Add("Message", ex.Message); string ExceptionString = "Api : GetRatingArea" + Environment.NewLine; ExceptionString += "Request : " + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(data) + Environment.NewLine; var fileName = "GetRatingArea - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, data); return(response); } }
public HttpResponseMessage SaveCarrier(IssuerMst objIssuer) { Response oResponse = new Response(); if (!ModelState.IsValid) { var Messages = string.Join(Environment.NewLine, ModelState.Values.SelectMany(r => r.Errors).Select(r => r.ErrorMessage)); oResponse.Status = false; oResponse.Message = Messages; HttpResponseMessage objResponse = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(objResponse); } using (var DB = new MHMDal.Models.MHM()) { try { var Issuer = DB.IssuerMsts.Add(objIssuer); oResponse.Status = true; oResponse.Message = "Success"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : SaveCarrier" + Environment.NewLine; ExceptionString += "Request : " + " objIssuer " + JsonConvert.SerializeObject(objIssuer) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "SaveCarrier - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
//[Authorize(Roles = "Admin")] public HttpResponseMessage CheckBenefitMapping(long CarrierId, long IssuerBenefitId, long CommonBenefitId) { Response oResponse = new Response(); try { using (var DB = new MHMDal.Models.MHM()) { Dictionary <string, object> res = new Dictionary <string, object>(); var MHMBenefitMapping = DB.MHMBenefitMappingMsts.Where(e => e.IssuerID == CarrierId && e.IssuerBenefitID == IssuerBenefitId).ToList(); res.Add("Status", "true"); if (MHMBenefitMapping.Count > 0 && MHMBenefitMapping.Count(r => r.MHMCommonBenefitID != CommonBenefitId) > 0) { res.Add("Message", "This Issuer Benefit already assign to another Issuer."); res.Add("BenefitMappingStatus", false); } else { res.Add("Message", "Success"); res.Add("BenefitMappingStatus", true); } return(Request.CreateResponse(HttpStatusCode.OK, res)); } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : CheckBenefitMapping" + Environment.NewLine; ExceptionString += "Request : " + " CarrierId " + CarrierId + " ,IssuerBenefitId " + IssuerBenefitId + " ,CommonBenefitId " + CommonBenefitId + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "CheckBenefitMapping - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); return(Request.CreateResponse(HttpStatusCode.BadRequest, oResponse)); } }
public HttpResponseMessage UpdateAllFinalNotSendCases([FromUri] List <int?> CaseStatusIds, string JobNumber, string JobRunStatus) { Dictionary <string, object> res = new Dictionary <string, object>(); using (var DB = new MHMDal.Models.MHM()) { try { var lstCases = DB.Cases.Where(r => r.JobNumber == JobNumber && CaseStatusIds.Contains(r.StatusId)).ToList(); if (JobRunStatus != null) { lstCases = lstCases.Where(r => r.CaseJobRunStatus == JobRunStatus).ToList(); } lstCases.ForEach(r => r.InProcessStatus = false); DB.SaveChanges(); var Job = DB.JobMasters.Where(r => r.JobNumber == JobNumber).FirstOrDefault(); Job.JobRunStatus = Convert.ToString(MHM.Api.Models.EnumStatusModel.JobRunStatus.NULL); DB.SaveChanges(); res.Add("Status", "true"); res.Add("Message", "Success"); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } catch (Exception ex) { res.Add("Status", "false"); res.Add("Message", "Failed"); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, res); return(response); } } }
public async Task <HttpResponseMessage> SendMail() { Response oResponse = new Response(); bool MailStatus = true; HttpContent requestContent = Request.Content; var Content = await requestContent.ReadAsStringAsync(); var JsonData = JsonConvert.DeserializeObject <JsonResponse>(Content); byte[] data = Convert.FromBase64String(JsonData.Html); string Html = System.Text.Encoding.UTF8.GetString(data); long CaseId = Convert.ToInt64(JsonData.CaseId); long ModifiedBy = Convert.ToInt64(JsonData.ModifiedBy); using (var DB = new MHMDal.Models.MHM()) { try { #region Generating PDF // read parameters from the webpage string baseUrl = "app.myhealthmath.com"; string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); int webPageWidth = 1024; int webPageHeight = 0; // instantiate a html to pdf converter object HtmlToPdf converter = new HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url PdfDocument doc = converter.ConvertHtmlString(Html, baseUrl); // save pdf document byte[] outPdfBuffer = doc.Save(); // close pdf document doc.Close(); #endregion string Mail = ""; var MailDetails = DB.JobMasters.Where(r => r.JobNumber == JsonData.JobNumber).Select(t => new { t.EmailSubjText, t.EmailBodyText, t.EmailSignText }).First(); string EmailSubjText = MailDetails.EmailSubjText.ToString(); string EmailBodyText = MailDetails.EmailBodyText.ToString(); string EmailSignText = MailDetails.EmailSignText.ToString(); if (EmailSubjText.Contains("##CaseTitle##")) { EmailSubjText = EmailSubjText.Replace("##CaseTitle##", JsonData.CaseTitle); } if (EmailBodyText.Contains("##ApplicantName##")) { EmailBodyText = EmailBodyText.Replace("##ApplicantName##", JsonData.ApplicantName.ToString()); } if (EmailSignText.Contains("##AgentName##")) { EmailSignText = EmailSignText.Replace("##AgentName##", JsonData.AgentName); } if (EmailSignText.Contains("##AgentEmail##")) { EmailSignText = EmailSignText.Replace("##AgentEmail##", JsonData.AgentEmail); } if (EmailSignText.Contains("##AgentPhone##")) { EmailSignText = EmailSignText.Replace("##AgentPhone##", String.Format("{0:(###) ###-####}", Convert.ToInt64(JsonData.AgentPhone))); } if (EmailBodyText.Contains("##PlanTotalCostRange##")) { EmailBodyText = EmailBodyText.Replace("##PlanTotalCostRange##", "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.PlanTotalCostRange))); } if (EmailBodyText.Contains("##TotalEmployerContribution##")) { var str = ""; if (Convert.ToDecimal(JsonData.EmployerHSAContribution) != 0 && Convert.ToDecimal(JsonData.EmployerHRAReimbursement) > 0) { str = "If you enroll in the " + JsonData.OptimalPlanName + " (your optimal plan), your employer will contribute approximately " + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.TotalEmployerContribution)) + " to your expenses. This contribution consists of:" + Environment.NewLine; str += "<ul><li>" + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.EmployerPremiumContribution)) + " to your premium</li>"; str += "<li>" + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.EmployerHSAContribution)) + " to your health savings account, and</li>"; str += "<li>an estimated " + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.EmployerHRAReimbursement)) + " in HRA reimbursements.</li></ul>"; } else if (Convert.ToDecimal(JsonData.EmployerHSAContribution) != 0 && Convert.ToDecimal(JsonData.EmployerHRAReimbursement) == 0) { str = "If you enroll in the " + JsonData.OptimalPlanName + " (your optimal plan), your employer will contribute approximately " + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.TotalEmployerContribution)) + " to your expenses. This contribution consists of:" + Environment.NewLine; str += "<ul><li>" + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.EmployerPremiumContribution)) + " to your premium</li>"; str += "<li>" + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.EmployerHSAContribution)) + " to your health savings account.</li></ul>"; } else if (Convert.ToDecimal(JsonData.EmployerHSAContribution) == 0 && Convert.ToDecimal(JsonData.EmployerHRAReimbursement) > 0) { str = "If you enroll in the " + JsonData.OptimalPlanName + " (your optimal plan), your employer will contribute approximately " + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.TotalEmployerContribution)) + " to your expenses. This contribution consists of:" + Environment.NewLine; str += "<ul><li>" + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.EmployerPremiumContribution)) + " to your premium</li>"; str += "<li>an estimated " + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.EmployerHRAReimbursement)) + " in HRA reimbursements.</li></ul>"; } else if (Convert.ToDecimal(JsonData.EmployerHSAContribution) == 0 && Convert.ToDecimal(JsonData.EmployerHRAReimbursement) == 0) { str = "If you enroll in the " + JsonData.OptimalPlanName + " (your optimal plan), your employer will contribute approximately " + "$" + String.Format("{0:n0}", Convert.ToDecimal(JsonData.TotalEmployerContribution)) + " to your premium."; } EmailBodyText = EmailBodyText.Replace("##TotalEmployerContribution##", str); } Mail = EmailBodyText + EmailSignText; Service.SendMailWithAttaitchment(JsonData.ApplicantEmail, JsonData.AgentEmail, "*****@*****.**", EmailSubjText, Mail, outPdfBuffer, JsonData.CaseTitle + ".pdf"); //var oCase = DB.Cases.Where(r => r.CaseID == CaseId).FirstOrDefault(); UpdateCaseToSent(CaseId, MailStatus, ModifiedBy); oResponse.Status = true; oResponse.Message = "Success"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } catch (Exception ex) { MailStatus = false; UpdateCaseToSent(CaseId, MailStatus, ModifiedBy); oResponse.Status = false; oResponse.Message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
public HttpResponseMessage GetZipCodes([FromUri] List <string> lstParameter, string BusinessYear, string searchby = null, string sortby = null, bool desc = true, int page = 0, int pageSize = 10) { Response oResponse = new Response(); Dictionary <string, object> res = new Dictionary <string, object>(); try { using (var DB = new MHMDal.Models.MHM()) { int skipRows = (page - 1) * pageSize; var lsttblZipCodes = DB.tblZipCodes.Join(DB.tblStateAbrevs, t1 => t1.State, t2 => t2.StateCode, (t1, t2) => new { t1.Zip, t1.State, t1.County, t1.CreatedDateTime, t2.StateName }).ToList(); if (!string.IsNullOrEmpty(searchby)) { lsttblZipCodes = lsttblZipCodes.Where(x => x.Zip.Contains(searchby)).ToList(); } //Carrier, Plan, IsActive , StateCode MetalLevel and MarketCover if (!string.IsNullOrEmpty(lstParameter[0])) { lsttblZipCodes = lsttblZipCodes.Where(x => x.State.ToLower().Contains(lstParameter[0].ToLower())).ToList(); } if (!string.IsNullOrEmpty(lstParameter[1])) { lsttblZipCodes = lsttblZipCodes.Where(x => x.County.ToLower().Contains(lstParameter[1].ToLower())).ToList(); } int total = lsttblZipCodes.Count(); if (total > 0) { //lstStateAbrevs = desc ? lstStateAbrevs.OrderByDescending(x => x.PlanId).Skip(skipRows).Take(pageSize).ToList() : lstStateAbrevs.OrderBy(x => x.PlanId).Skip(skipRows).Take(pageSize).ToList(); switch (sortby) { case "Zip": lsttblZipCodes = desc ? lsttblZipCodes.OrderByDescending(x => x.Zip).Skip(skipRows).Take(pageSize).ToList() : lsttblZipCodes.OrderBy(x => x.Zip).Skip(skipRows).Take(pageSize).ToList(); break; case "StateName": lsttblZipCodes = desc ? lsttblZipCodes.OrderByDescending(x => x.StateName).Skip(skipRows).Take(pageSize).ToList() : lsttblZipCodes.OrderBy(x => x.StateName).Skip(skipRows).Take(pageSize).ToList(); break; case "State": lsttblZipCodes = desc ? lsttblZipCodes.OrderByDescending(x => x.State).Skip(skipRows).Take(pageSize).ToList() : lsttblZipCodes.OrderBy(x => x.State).Skip(skipRows).Take(pageSize).ToList(); break; case "County": lsttblZipCodes = desc ? lsttblZipCodes.OrderByDescending(x => x.County).Skip(skipRows).Take(pageSize).ToList() : lsttblZipCodes.OrderBy(x => x.County).Skip(skipRows).Take(pageSize).ToList(); break; //case "Businessyear": // lsttblZipCodes = desc ? lsttblZipCodes.OrderByDescending(x => x.Businessyear).Skip(skipRows).Take(pageSize).ToList() : lsttblZipCodes.OrderBy(x => x.Businessyear).Skip(skipRows).Take(pageSize).ToList(); // break; default: lsttblZipCodes = desc ? lsttblZipCodes.OrderByDescending(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList() : lsttblZipCodes.OrderBy(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList(); break; } res.Add("Status", "true"); res.Add("Message", "Success"); res.Add("ZipCodes", lsttblZipCodes.Select(r => new { r.Zip, r.State, r.StateName, r.County, Businessyear = "" }) ); res.Add("TotalCount", total); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } else { res.Add("Status", "false"); res.Add("Message", "Zip Codes does not exist."); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : GetZipCodes" + Environment.NewLine; ExceptionString += "Request : " + " lstParameter " + lstParameter + " ,BusinessYear " + BusinessYear + " ,searchby " + searchby + " ,sortby " + sortby + " ,desc " + desc + " ,page " + page + " ,pageSize " + pageSize + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetZipCodes - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } }
public HttpResponseMessage GetAllFinalNotSendCases([FromUri] List <int?> CaseStatusIds, string JobNumber, string JobRunStatus) { try { using (var DB = new MHMDal.Models.MHM()) { var lstCases = DB.Cases.Where(r => r.JobNumber == JobNumber && CaseStatusIds.Contains(r.StatusId) && r.InProcessStatus == false).ToList(); if (JobRunStatus != null) { lstCases = lstCases.Where(r => r.CaseJobRunStatus == JobRunStatus).ToList(); } Dictionary <string, object> res = new Dictionary <string, object>(); if (lstCases.Count() > 0) { var oCase = lstCases.Take(1).FirstOrDefault(); oCase.InProcessStatus = true; DB.SaveChanges(); oCase.Applicant.City = oCase.Applicant.City != null?oCase.Applicant.City.Decrypt() : null; oCase.Applicant.Email = oCase.Applicant.Email != null?oCase.Applicant.Email.Decrypt() : null; oCase.Applicant.FirstName = oCase.Applicant.FirstName != null?oCase.Applicant.FirstName.Decrypt() : null; oCase.Applicant.LastName = oCase.Applicant.LastName != null?oCase.Applicant.LastName.Decrypt() : null; oCase.Applicant.Mobile = oCase.Applicant.Mobile != null?oCase.Applicant.Mobile.Decrypt() : null; oCase.Applicant.Street = oCase.Applicant.Street != null?oCase.Applicant.Street.Decrypt() : null; oCase.Applicant.State = oCase.Applicant.State != null?oCase.Applicant.State.Decrypt() : null; oCase.Applicant.Zip = oCase.Applicant.Zip != null?oCase.Applicant.Zip.Decrypt() : null; oCase.Notes = oCase.Notes != null?oCase.Notes.Decrypt() : null; DateTime date; oCase.Families.ToList().ForEach(r => { // r.Gender = r.Gender.Decrypt(); r.Gender = GenerateEncryptedString.GetDecryptedString(r.Gender); var DOB = GenerateEncryptedString.GetDecryptedString(r.DOB); var status = DateTime.TryParse(DOB, out date); if (!status) { date = DateTime.Parse(DOB, CultureInfo.CreateSpecificCulture("fr-FR")); } r.DOB = date.ToString("MM/dd/yyyy"); r.Criticalillnesses.ToList(); r.BenefitUserDetails.ToList().ForEach(t => { t.UsageNotes = t.UsageNotes != null ? t.UsageNotes.Decrypt() : null; }); }); oCase.CasePlanResults.ToList().ForEach(r => { r.GrossAnnualPremium = r.GrossAnnualPremium; r.FederalSubsidy = r.FederalSubsidy; r.NetAnnualPremium = r.NetAnnualPremium; r.MonthlyPremium = r.MonthlyPremium; r.Copays = r.Copays; r.PaymentsToDeductibleLimit = r.PaymentsToDeductibleLimit; r.CoinsuranceToOutOfPocketLimit = r.CoinsuranceToOutOfPocketLimit; r.ContributedToYourHSAAccount = r.ContributedToYourHSAAccount != null ? r.ContributedToYourHSAAccount : null; r.TaxSavingFromHSAAccount = r.TaxSavingFromHSAAccount; r.Medical = r.Medical; r.TotalPaid = r.TotalPaid; r.PaymentsByInsuranceCo = r.PaymentsByInsuranceCo; r.DeductibleSingle = r.DeductibleSingle; r.DeductibleFamilyPerPerson = r.DeductibleFamilyPerPerson; r.DeductibleFamilyPerGroup = r.DeductibleFamilyPerGroup; r.OPLSingle = r.OPLSingle; r.OPLFamilyPerPerson = r.OPLFamilyPerPerson; r.OPLFamilyPerGroup = r.OPLFamilyPerGroup; r.Coinsurance = r.Coinsurance; r.WorstCase = r.WorstCase; r.PlanName = r.PlanName; r.HRAReimbursedAmt = r.HRAReimbursedAmt; //test = test + 1; }); oCase.CasePlanResults = oCase.CasePlanResults.Take(5).ToList(); oCase.CaseStatusMst = oCase.CaseStatusMst; oCase.IssuerMst = oCase.IssuerMst; var objJobMaster = oCase.JobMaster; oCase.JobMaster = objJobMaster; res.Add("Status", "true"); res.Add("Message", "Success"); res.Add("Case", oCase); res.Add("TotalCount", lstCases.Count); } else { res.Add("Status", "true"); res.Add("Message", "Success"); res.Add("Case", ""); } HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } } catch (Exception ex) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, ex.ToString()); return(response); } }
public HttpResponseMessage SaveBenefitCost(BenefitCostViewModel oModel) { Dictionary <string, object> data = new Dictionary <string, object>(); if (!ModelState.IsValid) { string messages = string.Join(Environment.NewLine, ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); data.Add("Status", false); data.Add("Message", messages); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } try { using (var DB = new MHMDal.Models.MHM()) { var result = DB.MHMBenefitCostByAreaMsts.Where(m => m.RatingAreaID == oModel.RatingAreaID && m.StateCode == oModel.StateCode).ToList(); DB.MHMBenefitCostByAreaMsts.RemoveRange(result); //foreach (var item in result) //{ // MHMBenefitCostByAreaMst oMHMBenefitCostByAreaMst = new MHMBenefitCostByAreaMst(); // oMHMBenefitCostByAreaMst = item; // DB.MHMBenefitCostByAreaMsts.Remove(oMHMBenefitCostByAreaMst); //} // DB.MHMBenefitCostByAreaMsts.AddRange(oModel.Benefits); bool FinalStatus = false; foreach (var item in oModel.Benefits) { var Status = DB.MHMCommonBenefitsMsts.Select(r => r.MHMBenefitID).Contains(item.MHMBenefitId); if (Status) { MHMBenefitCostByAreaMst oMHMBenefitCost = new MHMBenefitCostByAreaMst(); oMHMBenefitCost.MHMBenefitId = item.MHMBenefitId; oMHMBenefitCost.RatingAreaID = oModel.RatingAreaID; oMHMBenefitCost.MHMBenefitCost = item.MHMBenefitCost; oMHMBenefitCost.StateCode = oModel.StateCode; oMHMBenefitCost.Createdby = oModel.Createdby; oMHMBenefitCost.CreatedDateTime = DateTime.Now; DB.MHMBenefitCostByAreaMsts.Add(oMHMBenefitCost); DB.SaveChanges(); } else { FinalStatus = true; } } //Remove Cache of PlanBenefitMaster var MHMBenefitCostByAreaMasterFromCache = MHMCache.GetMyCachedItem("MHMBenefitCostByAreaMaster"); if (MHMBenefitCostByAreaMasterFromCache != null) { MHMCache.RemoveMyCachedItem("MHMBenefitCostByAreaMaster"); } data.Add("Status", true); data.Add("Message", FinalStatus ? "Success ! but some benefit deleted" : "Success"); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } } catch (Exception ex) { data.Add("Status", false); data.Add("Message", ex.Message); string ExceptionString = "Api : SaveBenefitCost" + Environment.NewLine; ExceptionString += "Request : " + JsonConvert.SerializeObject(oModel) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(data) + Environment.NewLine; var fileName = "SaveBenefitCost - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, data); return(response); } }
public HttpResponseMessage AllBenefits(string searchBy, string sortby, bool desc, int page, int pageSize, long filterByCategory = 0) { Dictionary <string, object> data = new Dictionary <string, object>(); using (var DB = new MHMDal.Models.MHM()) { try { List <MHMCommonBenefitsMst> oBenefitlist = new List <MHMCommonBenefitsMst>(); oBenefitlist = DB.MHMCommonBenefitsMsts.ToList(); int skipRows = (page - 1) * pageSize; if (!string.IsNullOrEmpty(searchBy)) { //oBenefitlist = oBenefitlist.Where(x => x.MHMBenefitName.ToLower().StartsWith(searchBy.ToLower()) || x.CategoryId == (int.TryParse(searchBy, out num1) ? num1 : 0)).ToList(); oBenefitlist = oBenefitlist.Where(x => x.MHMBenefitName.ToLower().Contains(searchBy.ToLower())).ToList(); } if (filterByCategory > 0) { oBenefitlist = oBenefitlist.Where(x => x.CategoryId == filterByCategory).ToList(); } int totalRecords = oBenefitlist.Count(); if (totalRecords > 0) { switch (sortby) { case "MHMBenefitID": oBenefitlist = desc ? oBenefitlist.OrderByDescending(x => x.MHMBenefitID).Skip(skipRows).Take(pageSize).ToList() : oBenefitlist.OrderBy(x => x.MHMBenefitID).Skip(skipRows).Take(pageSize).ToList(); break; case "MHMBenefitName": oBenefitlist = desc ? oBenefitlist.OrderByDescending(x => x.MHMBenefitName).Skip(skipRows).Take(pageSize).ToList() : oBenefitlist.OrderBy(x => x.MHMBenefitName).Skip(skipRows).Take(pageSize).ToList(); break; case "CategoryName": oBenefitlist = desc ? oBenefitlist.OrderByDescending(x => x.CategoryMst.CategoryName).Skip(skipRows).Take(pageSize).ToList() : oBenefitlist.OrderBy(x => x.CategoryMst.CategoryName).Skip(skipRows).Take(pageSize).ToList(); break; case "CreatedDateTime": oBenefitlist = desc ? oBenefitlist.OrderByDescending(x => x.MHMBenefitID).Skip(skipRows).Take(pageSize).ToList() : oBenefitlist.OrderBy(x => x.MHMBenefitID).Skip(skipRows).Take(pageSize).ToList(); break; default: oBenefitlist = desc ? oBenefitlist.OrderByDescending(x => x.MHMBenefitID).Skip(skipRows).Take(pageSize).ToList() : oBenefitlist.OrderBy(x => x.MHMBenefitID).Skip(skipRows).Take(pageSize).ToList(); break; } #region // For dynamic getting sortby //ParameterExpression param = Expression.Parameter(typeof(MHMCommonBenefitsMst), "model"); //Expression propertyAccess = Expression.Property(param, sortby); //var funcType = typeof(Func<object,object>).MakeGenericType(typeof(MHMCommonBenefitsMst), propertyAccess.Type); //LambdaExpression Sortby = Expression.Lambda(funcType, propertyAccess, param); // var param = Expression.Parameter(typeof(MHMCommonBenefitsMst), "model"); // var Sortby =Expression.Lambda<Func<MHMCommonBenefitsMst, object>>(Expression.Property(param, "MHMBenefitID"), param); //if (desc) // oBenefitlist = DB.MHMCommonBenefitsMsts.OrderByDescending(Sortby).Skip(skipRows).Take(pageSize).ToList(); //else // oBenefitlist = DB.MHMCommonBenefitsMsts.OrderBy(Sortby).Skip(skipRows).Take(pageSize).ToList(); #endregion var lstUsers = DB.Users.ToList(); oBenefitlist.ForEach(r => r.CategoryMst = r.CategoryMst); data.Add("Status", true); data.Add("Message", "Success"); data.Add("Benefits", oBenefitlist.Select(r => new { r.MHMBenefitID, r.MHMBenefitName, r.CreatedDateTime, r.Createdby, r.CategoryId, r.CategoryMst.CategoryName, r.IsDefault, CreatedByName = r.Createdby != null ? lstUsers.Where(t => t.UserID == r.Createdby).FirstOrDefault().FirstName + " " + lstUsers.Where(t => t.UserID == r.Createdby).FirstOrDefault().LastName : "" })); data.Add("TotalRecords", totalRecords); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } else { data.Add("Status", "false"); data.Add("Message", "Benefit cannot be found. "); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, data); return(response); } } catch (Exception ex) { data.Add("Status", false); data.Add("Message", ex.Message); string ExceptionString = "Api : AllBenefits" + Environment.NewLine; ExceptionString += "Request : " + " filterByCategory " + filterByCategory + " ,searchBy " + searchBy + " ,sortby " + sortby + " ,desc " + desc + " ,page " + page + " ,pageSize " + pageSize + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(data) + Environment.NewLine; var fileName = "AllBenefits - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, data); return(response); } } }
public HttpResponseMessage UpdateCarrier(IssuerMst objIssuer) { Response oResponse = new Response(); if (!ModelState.IsValid) { var Messages = string.Join(Environment.NewLine, ModelState.Values.SelectMany(r => r.Errors).Select(r => r.ErrorMessage)); oResponse.Status = false; oResponse.Message = Messages; HttpResponseMessage objResponse = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(objResponse); } using (var DB = new MHMDal.Models.MHM()) { try { var Issuer = DB.IssuerMsts.Where(r => r.Id == objIssuer.Id).FirstOrDefault(); if (Issuer != null) { Issuer.IssuerCode = objIssuer.IssuerCode; Issuer.IssuerName = objIssuer.IssuerName; Issuer.Abbreviations = objIssuer.Abbreviations; Issuer.StateCode = objIssuer.StateCode; Issuer.Status = objIssuer.Status; Issuer.ModifiedBy = objIssuer.ModifiedBy; Issuer.ModifiedDateTime = System.DateTime.Now; DB.SaveChanges(); var IssuerMasterFromCache = MHMCache.GetMyCachedItem("IssuerMaster"); if (IssuerMasterFromCache != null) { MHMCache.RemoveMyCachedItem("IssuerMaster"); } oResponse.Status = true; oResponse.Message = "Success"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } else { oResponse.Status = true; oResponse.Message = "Issuer not found"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : UpdateCarrier" + Environment.NewLine; ExceptionString += "Request : " + " objIssuer " + JsonConvert.SerializeObject(objIssuer) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "UpdateCarrier - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
public HttpResponseMessage GetEmployers(long?employerid, string searchby = null, string sortby = null, bool desc = true, int page = 0, int pageSize = 10) { Response oResponse = new Response(); Dictionary <string, object> res = new Dictionary <string, object>(); using (var DB = new MHMDal.Models.MHM()) { try { int skipRows = (page - 1) * pageSize; var lstEmployerMsts = DB.EmployerMsts.ToList(); if (!string.IsNullOrEmpty(searchby)) { lstEmployerMsts = lstEmployerMsts.Where(r => r.EmployerName.ToLower().Contains(searchby.ToLower())).ToList(); } if (employerid != null) { lstEmployerMsts = lstEmployerMsts.Where(r => r.EmployerId == employerid).ToList(); } int total = lstEmployerMsts.Count(); if (total > 0) { switch (sortby) { case "EmployerId": lstEmployerMsts = desc ? lstEmployerMsts.OrderByDescending(r => r.EmployerId).Skip(skipRows).Take(pageSize).ToList() : lstEmployerMsts.OrderBy(r => r.EmployerId).Skip(skipRows).Take(pageSize).ToList(); break; case "EmployerName": lstEmployerMsts = desc ? lstEmployerMsts.OrderByDescending(r => r.EmployerName).Skip(skipRows).Take(pageSize).ToList() : lstEmployerMsts.OrderBy(r => r.EmployerName).Skip(skipRows).Take(pageSize).ToList(); break; default: lstEmployerMsts = desc ? lstEmployerMsts.OrderByDescending(r => r.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList() : lstEmployerMsts.OrderBy(r => r.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList(); break; } res.Add("Status", "true"); res.Add("Message", "Success"); res.Add("EmployerMsts", lstEmployerMsts.Select(r => new { r.EmployerId, r.EmployerName, r.CreatedDateTime }) ); res.Add("TotalCount", total); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } else { res.Add("Status", "false"); res.Add("Message", "EmployerMsts does not exist."); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : GetEmployers" + Environment.NewLine; ExceptionString += "Request : " + " employerid " + employerid + " ,searchby " + searchby + " ,sortby " + sortby + " ,desc " + desc + " ,page " + page + " ,pageSize " + pageSize + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetEmployers - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
public HttpResponseMessage GetAllCarrier(string issuerCode, string searchby = null, string sortby = null, bool desc = true, int page = 0, int pageSize = 10) { Response oResponse = new Response(); Dictionary <string, object> res = new Dictionary <string, object>(); using (var DB = new MHMDal.Models.MHM()) { try { int skipRows = (page - 1) * pageSize; var lstIssuerMasters = DB.IssuerMsts.ToList(); if (!string.IsNullOrEmpty(searchby)) { lstIssuerMasters = lstIssuerMasters.Where(x => x.IssuerName.ToLower().Contains(searchby.ToLower())).ToList(); } if (issuerCode != null) { lstIssuerMasters = lstIssuerMasters.Where(x => x.IssuerCode.ToLower() == issuerCode.ToLower()).ToList(); } //Carrier, Plan, IsActive , StateCode MetalLevel and MarketCover //if (!string.IsNullOrEmpty(lstParameter[0])) //{ // lstJobMasters = lstJobMasters.Where(x => x.EmployerId == Convert.ToInt64(lstParameter[0])).ToList(); //} int total = lstIssuerMasters.Count(); if (total > 0) { //lstPlanAttribute = desc ? lstPlanAttribute.OrderByDescending(x => x.PlanId).Skip(skipRows).Take(pageSize).ToList() : lstPlanAttribute.OrderBy(x => x.PlanId).Skip(skipRows).Take(pageSize).ToList(); switch (sortby) { case "IssuerName": lstIssuerMasters = desc ? lstIssuerMasters.OrderByDescending(x => x.IssuerName).Skip(skipRows).Take(pageSize).ToList() : lstIssuerMasters.OrderBy(x => x.IssuerName).Skip(skipRows).Take(pageSize).ToList(); break; case "EmployerName": lstIssuerMasters = desc ? lstIssuerMasters.OrderByDescending(x => x.IssuerCode).Skip(skipRows).Take(pageSize).ToList() : lstIssuerMasters.OrderBy(x => x.IssuerCode).Skip(skipRows).Take(pageSize).ToList(); break; case "CreatedDateTime": lstIssuerMasters = desc ? lstIssuerMasters.OrderByDescending(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList() : lstIssuerMasters.OrderBy(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList(); break; default: lstIssuerMasters = desc ? lstIssuerMasters.OrderByDescending(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList() : lstIssuerMasters.OrderBy(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList(); break; } res.Add("Status", true); res.Add("Message", "success"); res.Add("lstIssuerMasters", lstIssuerMasters); res.Add("TotalCount", total); HttpResponseMessage objResponse = Request.CreateResponse(HttpStatusCode.OK, res); return(objResponse); } else { res.Add("Status", "failed"); res.Add("Message", "IssuerMasters does not exist"); HttpResponseMessage objResponse = Request.CreateResponse(HttpStatusCode.OK, res); return(objResponse); } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.ToString(); string ExceptionString = "Api : GetAllCarrier" + Environment.NewLine; ExceptionString += "Request : " + " issuerCode " + issuerCode + " ,searchby " + searchby + " ,sortby " + sortby + " ,desc " + desc + " ,page " + page + " ,pageSize " + pageSize + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetAllCarrier - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
public HttpResponseMessage DeleteBenefit(long id) { Response oResponse = new Response(); using (var DB = new MHMDal.Models.MHM()) { MHMCommonBenefitsMst mHMCommonBenefitsMst = DB.MHMCommonBenefitsMsts.Find(id); if (mHMCommonBenefitsMst == null) { oResponse.Status = false; oResponse.Message = "Benefit cannot be found. "; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.NoContent, oResponse); return(response); } using (var dbContextTransaction = DB.Database.BeginTransaction()) { try { var status = DB.BenefitUserDetails.Where(r => r.MHMMappingBenefitId == mHMCommonBenefitsMst.MHMBenefitID).FirstOrDefault(); if (status == null) { var MHMBenefitMappingMsts = DB.MHMBenefitMappingMsts.Where(r => r.MHMCommonBenefitID == mHMCommonBenefitsMst.MHMBenefitID); var MHMBenefitCostByAreaMsts = DB.MHMBenefitCostByAreaMsts.Where(r => r.MHMBenefitId == mHMCommonBenefitsMst.MHMBenefitID); DB.MHMBenefitMappingMsts.RemoveRange(MHMBenefitMappingMsts); DB.MHMBenefitCostByAreaMsts.RemoveRange(MHMBenefitCostByAreaMsts); DB.MHMCommonBenefitsMsts.Remove(mHMCommonBenefitsMst); DB.SaveChanges(); oResponse.Status = true; oResponse.Message = "Success"; dbContextTransaction.Commit(); //Remove Cache of MHMBenefitMappingMaster var MHMBenefitMappingMasterFromCache = MHMCache.GetMyCachedItem("MHMBenefitMappingMaster"); if (MHMBenefitMappingMasterFromCache != null) { MHMCache.RemoveMyCachedItem("MHMBenefitMappingMaster"); } //Remove Cache of MHMBenefitCostByAreaMaster var MHMBenefitCostByAreaMasterFromCache = MHMCache.GetMyCachedItem("MHMBenefitCostByAreaMaster"); if (MHMBenefitCostByAreaMasterFromCache != null) { MHMCache.RemoveMyCachedItem("MHMBenefitCostByAreaMaster"); } HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } else { oResponse.Status = false; oResponse.Message = "This benefit is used in a case hence can't be deleted"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : DeleteBenefit" + Environment.NewLine; ExceptionString += "Request : " + " id " + id + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "DeleteBenefit - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); dbContextTransaction.Rollback(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } } }
public HttpResponseMessage UpdateEmployer(EmployerMst employermst) { Response oResponse = new Response(); if (!ModelState.IsValid) { string messages = string.Join(Environment.NewLine, ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); oResponse.Status = false; oResponse.Message = messages; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } using (var DB = new MHMDal.Models.MHM()) { try { var employer = DB.EmployerMsts.Find(employermst.EmployerId); HttpResponseMessage response; if (employer == null) { oResponse.Status = false; oResponse.Message = "Employer cannot be found."; response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } employer.EmployerName = employermst.EmployerName; employer.ModifiedDateTime = DateTime.Now; DB.SaveChanges(); oResponse.Status = true; oResponse.Message = "Success"; response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } catch (DbUpdateConcurrencyException ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : UpdateEmployer" + Environment.NewLine; ExceptionString += "Request : " + " employermst " + JsonConvert.SerializeObject(employermst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "UpdateEmployer - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : UpdateEmployer" + Environment.NewLine; ExceptionString += "Request : " + " employermst " + JsonConvert.SerializeObject(employermst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "UpdateEmployer - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } }
public HttpResponseMessage PostMHMCommonBenefitsMst(MHMCommonBenefitsMst mHMCommonBenefitsMst) { Response oResponse = new Response(); if (!ModelState.IsValid) { string messages = string.Join(Environment.NewLine, ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); oResponse.Status = false; oResponse.Message = messages; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } using (var DB = new MHMDal.Models.MHM()) { using (var dbContextTransaction = DB.Database.BeginTransaction()) { try { var Benefit = DB.MHMCommonBenefitsMsts.Where(r => r.MHMBenefitName == mHMCommonBenefitsMst.MHMBenefitName).FirstOrDefault(); if (Benefit == null) { mHMCommonBenefitsMst.CreatedDateTime = DateTime.Now; DB.MHMCommonBenefitsMsts.Add(mHMCommonBenefitsMst); //mHMCommonBenefitsMst.MHMBenefitMappingMsts.ToList().ForEach(r => r.MHMCommonBenefitID = mHMCommonBenefitsMst.MHMBenefitID); DB.SaveChanges(); oResponse.Status = true; oResponse.Message = "Success"; dbContextTransaction.Commit(); //Remove Cache of PlanBenefitMaster var PlanAttributeMasterFromCache = MHMCache.GetMyCachedItem("MHMBenefitMappingMaster"); if (PlanAttributeMasterFromCache != null) { MHMCache.RemoveMyCachedItem("MHMBenefitMappingMaster"); } HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } else { oResponse.Status = false; oResponse.Message = "Benefit name already exists."; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : PostMHMCommonBenefitsMst" + Environment.NewLine; ExceptionString += "Request : " + JsonConvert.SerializeObject(mHMCommonBenefitsMst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "PostMHMCommonBenefitsMst - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); dbContextTransaction.Rollback(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } } }
public HttpResponseMessage PutMHMCommonBenefitsMst(MHMCommonBenefitsMst mHMCommonBenefitsMst) { Response oResponse = new Response(); if (!ModelState.IsValid) { string messages = string.Join(Environment.NewLine, ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); oResponse.Status = false; oResponse.Message = messages; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } using (var DB = new MHMDal.Models.MHM()) { List <MHMBenefitMappingMst> newBenefits = mHMCommonBenefitsMst.MHMBenefitMappingMsts.ToList(); using (var dbContextTransaction = DB.Database.BeginTransaction()) { try { var mhmCommonBenefit = DB.MHMCommonBenefitsMsts.Find(mHMCommonBenefitsMst.MHMBenefitID); if (mhmCommonBenefit == null) { oResponse.Status = false; oResponse.Message = "Benefit cannot be found."; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } mhmCommonBenefit.MHMBenefitName = mHMCommonBenefitsMst.MHMBenefitName; mhmCommonBenefit.CategoryId = mHMCommonBenefitsMst.CategoryId; mhmCommonBenefit.IsDefault = mHMCommonBenefitsMst.IsDefault; mhmCommonBenefit.ModifiedDateTime = DateTime.Now; DB.SaveChanges(); newBenefits.ForEach(r => r.MHMCommonBenefitID = mhmCommonBenefit.MHMBenefitID); } catch (Exception ex) { var sqlException = ex.InnerException.InnerException as System.Data.SqlClient.SqlException; if (sqlException.Number == 2601 || sqlException.Number == 2627) { oResponse.Status = false; oResponse.Message = "Benefit name already exists."; string ExceptionString = "Api : PutMHMCommonBenefitsMst" + Environment.NewLine; ExceptionString += "Request : " + JsonConvert.SerializeObject(mHMCommonBenefitsMst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "PutMHMCommonBenefitsMst - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } else { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : PutMHMCommonBenefitsMst" + Environment.NewLine; ExceptionString += "Request : " + JsonConvert.SerializeObject(mHMCommonBenefitsMst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "PutMHMCommonBenefitsMst - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); dbContextTransaction.Rollback(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } //DB.Entry(mHMCommonBenefitsMst).State = EntityState.Modified; try { foreach (var item in mHMCommonBenefitsMst.MHMBenefitMappingMsts) { var temp = DB.MHMBenefitMappingMsts.Where(r => r.Id == item.Id).FirstOrDefault(); if (temp != null) { temp.IssuerBenefitID = item.IssuerBenefitID; temp.ModifiedBy = mHMCommonBenefitsMst.Createdby; temp.ModifiedDateTime = System.DateTime.Now; } else { MHMBenefitMappingMst obj = new MHMBenefitMappingMst(); obj.IssuerID = item.IssuerID; obj.MHMCommonBenefitID = item.MHMCommonBenefitID; obj.IssuerBenefitID = item.IssuerBenefitID; obj.Createdby = mHMCommonBenefitsMst.Createdby; obj.CreatedDateTime = System.DateTime.Now; DB.MHMBenefitMappingMsts.Add(obj); } DB.SaveChanges(); } dbContextTransaction.Commit(); //Remove Cache of PlanBenefitMaster var PlanAttributeMasterFromCache = MHMCache.GetMyCachedItem("MHMBenefitMappingMaster"); if (PlanAttributeMasterFromCache != null) { MHMCache.RemoveMyCachedItem("MHMBenefitMappingMaster"); } oResponse.Status = true; oResponse.Message = "Success"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } catch (DbUpdateConcurrencyException ex) { if (!MHMCommonBenefitsMstExists(mHMCommonBenefitsMst.MHMBenefitID)) { oResponse.Status = false; oResponse.Message = "Benefit cannot be found. "; string ExceptionString = "Api : PutMHMCommonBenefitsMst" + Environment.NewLine; ExceptionString += "Request : " + JsonConvert.SerializeObject(mHMCommonBenefitsMst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "PutMHMCommonBenefitsMst - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, oResponse); return(response); } else { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : PutMHMCommonBenefitsMst" + Environment.NewLine; ExceptionString += "Request : " + JsonConvert.SerializeObject(mHMCommonBenefitsMst) + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "PutMHMCommonBenefitsMst - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); dbContextTransaction.Rollback(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } } } } }
public HttpResponseMessage GetRatingAreas([FromUri] List <string> lstParameter, string BusinessYear, string searchby = null, string sortby = null, bool desc = true, int page = 0, int pageSize = 10) { Response oResponse = new Response(); Dictionary <string, object> res = new Dictionary <string, object>(); try { using (var DB = new MHMDal.Models.MHM()) { int skipRows = (page - 1) * pageSize; var lstRatingAreas = DB.tblRatingAreas.ToList(); if (!string.IsNullOrEmpty(searchby)) { //oCase.Applicant.City != null ? oCase.Applicant.City.Encrypt() : null; //if (searchby != null) { lstRatingAreas = lstRatingAreas.Where(r => r.CountyName != null || r.ThreeDigitZipCode != null).ToList(); } lstRatingAreas.ForEach( x => x.CountyName = x.CountyName != null ? x.CountyName : "" ); lstRatingAreas.ForEach( x => x.ThreeDigitZipCode = x.ThreeDigitZipCode != null ? x.ThreeDigitZipCode : "" ); lstRatingAreas = lstRatingAreas.Where(x => x.CountyName.ToLower().Contains(searchby.ToLower()) || x.ThreeDigitZipCode.ToString().Contains(searchby)).ToList(); //lstRatingAreas = lstRatingAreas.Where(x => x.CountyName.ToLower() == searchby.ToLower()).ToList(); } if (BusinessYear != null) { lstRatingAreas = lstRatingAreas.Where(x => x.Businessyear == BusinessYear).ToList(); } //Carrier, Plan, IsActive , StateCode MetalLevel and MarketCover if (!string.IsNullOrEmpty(lstParameter[0])) { lstRatingAreas = lstRatingAreas.Where(x => x.StateCode == lstParameter[0]).ToList(); } if (!string.IsNullOrEmpty(lstParameter[1])) { lstRatingAreas = lstRatingAreas.Where(x => x.RatingAreaID == Convert.ToInt64(lstParameter[1])).ToList(); } if (!string.IsNullOrEmpty(lstParameter[2])) { lstRatingAreas = lstRatingAreas.Where(x => x.MarketCoverage == lstParameter[2].ToString()).ToList(); } int total = lstRatingAreas.Count(); if (total > 0) { //lstStateAbrevs = desc ? lstStateAbrevs.OrderByDescending(x => x.PlanId).Skip(skipRows).Take(pageSize).ToList() : lstStateAbrevs.OrderBy(x => x.PlanId).Skip(skipRows).Take(pageSize).ToList(); switch (sortby) { case "Id": lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.Id).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.Id).Skip(skipRows).Take(pageSize).ToList(); break; case "CountyName": lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.CountyName).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.CountyName).Skip(skipRows).Take(pageSize).ToList(); break; case "ThreeDigitZipCode": lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.ThreeDigitZipCode).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.ThreeDigitZipCode).Skip(skipRows).Take(pageSize).ToList(); break; case "StateCode": lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.StateCode).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.StateCode).Skip(skipRows).Take(pageSize).ToList(); break; case "RatingAreaName": lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.tblRatingAreaMst.RatingAreaName).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.tblRatingAreaMst.RatingAreaName).Skip(skipRows).Take(pageSize).ToList(); break; case "FipsCounty": lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.MarketCoverage).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.MarketCoverage).Skip(skipRows).Take(pageSize).ToList(); break; case "Businessyear": lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.Businessyear).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.Businessyear).Skip(skipRows).Take(pageSize).ToList(); break; default: lstRatingAreas = desc ? lstRatingAreas.OrderByDescending(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList() : lstRatingAreas.OrderBy(x => x.CreatedDateTime).Skip(skipRows).Take(pageSize).ToList(); break; } lstRatingAreas.ForEach(r => r.tblRatingAreaMst = r.tblRatingAreaMst); res.Add("Status", "true"); res.Add("Message", "Success"); res.Add("RatingAreas", lstRatingAreas.Select(r => new { r.Id, r.CountyName, r.ThreeDigitZipCode, r.StateCode, r.RatingAreaID, r.tblRatingAreaMst.RatingAreaName, r.MarketCoverage, r.Businessyear }) ); res.Add("TotalCount", total); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } else { res.Add("Status", "false"); res.Add("Message", "RatingAreas does not exist."); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res); return(response); } } } catch (Exception ex) { oResponse.Status = false; oResponse.Message = ex.Message; string ExceptionString = "Api : GetRatingAreas" + Environment.NewLine; ExceptionString += "Request : " + " lstParameter " + lstParameter + " ,BusinessYear " + BusinessYear + " ,searchby " + searchby + " ,sortby " + sortby + " ,desc " + desc + " ,page " + page + " ,pageSize " + pageSize + Environment.NewLine; ExceptionString += "Exception : " + JsonConvert.SerializeObject(oResponse) + Environment.NewLine; var fileName = "GetRatingAreas - " + System.DateTime.Now.ToString("MM-dd-yyyy hh-mm-ss"); Helpers.Service.LogError(fileName, ExceptionString); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, oResponse); return(response); } }