private async void btnSubmit_Click(object sender, EventArgs e) { if (ValidateChildren()) { var request = new InsuranceInsertUpdateRequest { Name = txtName.Text, Price = float.Parse(txtPrice.Text) }; InsuranceModel entity = null; if (_insuranceId.HasValue) { entity = await _insuranceService.Update <InsuranceModel>(int.Parse(_insuranceId.ToString()), request); } else { entity = await _insuranceService.Insert <InsuranceModel>(request); } if (entity != null) { MessageBox.Show("Success!"); if (Form.ActiveForm != null) { Form.ActiveForm.Close(); } } } }
/// <summary> /// Converts the insurance entity to model /// </summary> /// <param name="ins"></param> /// <returns></returns> private InsuranceModel ConvertToInsuranceModel(tblInsuranceAgency ins) { InsuranceModel model = new InsuranceModel(); using (var context = new lifeflightapps()) { var contacts = context.tblInsuranceAgencyContacts.Where(x => x.InsuranceID == ins.INSURANCEID).ToList(); List <InsuranceContactModel> contactModels = new List <InsuranceContactModel>(); contactModels = ConvertToContactsModel(contacts); InsuranceModel insModel = new InsuranceModel() { InsuranceId = ins.INSURANCEID, InsuranceName = ins.INSAGENCYNAME, Description = ins.DESCRIPTION, Instructions = ins.INSTRUCTIONS, InsurancePhone = ins.INSURANCEPHONE, InsuranceFax = ins.INSURANCEFAX, PreAuthRequired = ins.PREAUTHREQUIRED.HasValue ? ins.PREAUTHREQUIRED.Value : false, HasOwnPaperWork = ins.HASOWNPAPEROWORK.HasValue ? ins.HASOWNPAPEROWORK.Value : false, CreatedBy = ins.CREATEDBY, CreatedOn = ins.CREATEDON, contactModels = contactModels }; model = insModel; } return(model); }
public void EditData(MouseEventArgs e, InsuranceModel model) { ShowEditData = true; Model = model; FrequencyDays = Model.PaymentFrequencyDays ?? 0; StateHasChanged(); }
public static void UpdateInsuranceCurrentBalance(string connString, int patientId, int insuranceProviderId, int currentUserId, double amount, bool isDeduct = false) { BillingDbContext dbContext = new BillingDbContext(connString); try { InsuranceModel insurance = dbContext.Insurances.Where(ins => ins.PatientId == patientId && ins.InsuranceProviderId == insuranceProviderId).FirstOrDefault(); if (insurance != null) { insurance.CurrentBalance = isDeduct ? insurance.CurrentBalance - amount : amount; insurance.ModifiedOn = DateTime.Now; insurance.ModifiedBy = currentUserId; dbContext.Entry(insurance).State = EntityState.Modified; dbContext.SaveChanges(); } else { throw new Exception("Unable to update Insurance Balance. Detail: Insurance object is null."); } } catch (Exception ex) { throw new Exception("Unable to update Insurance Balance. Detail:" + ex.ToString()); } }
public InsuranceBase() { Model = new InsuranceModel { Created = DateTime.UtcNow }; ShowEditData = false; InsuranceModels = new List <InsuranceModel>(); IncidentTypes = Enum.GetValues(typeof(IncidentType)).Cast <IncidentType>().Select(x => new IncidentTypeModel() { Name = x.ToString(), Value = (int)x }); FrequencyModels = new List <FrequencyModel>(); FrequencyModels.Add(new FrequencyModel() { Name = "Unknown", Value = 0 }); FrequencyModels.Add(new FrequencyModel() { Name = "Monthly", Value = 30 }); FrequencyModels.Add(new FrequencyModel() { Name = "Yearly", Value = 365 }); }
private void FindPolicies() { Records = new ObservableCollection <InsuranceModel>(); // Validate CustomerId int id; var idValid = int.TryParse(CustomerId, out id); if (!idValid) { return; } // get the records var records = _context.Insurance_tbl.Where(r => r.CustomerId == id).ToList(); // Get all the insurance companies, saves requesting db each time. var companies = _context.InsuranceCompanies_tbl.ToList(); // Structure results foreach (var record in records) { var newModel = new InsuranceModel() { StartDate = record.StartDate, EndDate = record.EndDate, Reference = record.Reference, Company = companies.First(r => r.Id == record.InsuranceCompanyId).Name }; Records.Add(newModel); } }
public async Task <ActionResult> Edit(InsuranceModel model) { try { if (!ModelState.IsValid) { TempData["message"] = ModelState.ErrorGathering(); } var insur = await _context.Insurances.FirstOrDefaultAsync(x => x.Id.Equals(model.Id)); if (insur != null) { insur.Name = model.Name; _context.Insurances.Update(insur); await _context.SaveChangesAsync(); } else { TempData["message"] = "Insurance not found."; } return(RedirectToAction(nameof(Index))); } catch (Exception ex) { TempData["message"] = ex.Message; return(View()); } }
//Business Logics for Motor Insurance private bool RecordNewMotorInsurance(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage) { ValidateAddInsurance validation = new ValidateAddInsurance(); bool isCorrectAge = validation.ValidateForAge(client.Age); //_repository.Create(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage); throw new NotImplementedException(); }
public async Task <ActionResult> Edit(int Id) { InsuranceModel model = new InsuranceModel(); var medCat = await _context.Insurances.FirstOrDefaultAsync(x => x.Id.Equals(Id)); model.Name = medCat.Name; return(View(model)); }
public void AddData(MouseEventArgs e) { ShowEditData = true; Model = new InsuranceModel { Created = DateTime.UtcNow }; StateHasChanged(); }
/// <summary> /// Make a DB call to get the insurance details /// </summary> /// <param name="insAgencyId"></param> /// <returns></returns> public InsuranceModel GetInsuranceFromDB(int insAgencyId) { InsuranceModel model = new InsuranceModel(); tblInsuranceAgency insuranceAgency = new tblInsuranceAgency(); using (var context = new lifeflightapps()) { insuranceAgency = context.tblInsuranceAgencies.Find(insAgencyId); model = ConvertToInsuranceModel(insuranceAgency); } return(model); }
public InsuranceModel GetDefaultInsurance() { InsuranceModel insuranceModel = new InsuranceModel(); using (ISession session = NHibernateSession.OpenSession()) // Open a session to conect to the database { var insurance = session.Query <Insurance>().FirstOrDefault(c => !c.Deleted.HasValue); if (insurance != null) { insuranceModel = insurance.ToInsuranceModel(); } } return(insuranceModel); }
public static InsuranceModel GetInsuranceModelFromInsPatientVM(GovInsurancePatientVM govPatientVM) { InsuranceModel retInsInfo = new InsuranceModel() { InsuranceProviderId = govPatientVM.InsuranceProviderId, InsuranceName = govPatientVM.InsuranceName, IMISCode = govPatientVM.IMISCode, CreatedOn = DateTime.Now, InitialBalance = govPatientVM.InitialBalance, CurrentBalance = govPatientVM.CurrentBalance }; return(retInsInfo); }
public InsuranceModel GetInsuranceById(InsuranceId InsuranceId) { InsuranceModel model = new InsuranceModel(); using (ISession session = NHibernateSession.OpenSession()) // Open a session to conect to the database { var dbItem = session.Query <Insurance>().FirstOrDefault(c => c.InsuranceId == InsuranceId.Value); if (dbItem != null) { model = dbItem.ToInsuranceModel(); } } return(model); }
//Record Insurance public bool Record(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage) { InsuranceModel.InsuranceTypes type = insurance.InsuranceType; switch (type) { case InsuranceModel.InsuranceTypes.MOTOR_INSURANCE: return(RecordNewMotorInsurance(insurance, client, policyCoverage, document, coverage)); case InsuranceModel.InsuranceTypes.LIFE_INSURANCE: return(RecordNewLifeInsurance(insurance, client, policyCoverage, document, coverage)); default: return(false); } //_repository.Create(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage); }
/// <summary> /// Add record in Vendor Package Relationship Table. /// </summary> /// <param name="record">The Model</param> /// <returns> /// Vendor id from vendor Package Relationship Table. /// </returns> /// <exception cref="ArgumentNullException">Vendor</exception> public async Task <int?> UpdateInsuranceMasterAsync(InsuranceModel record) { try { if (record == null) { throw new ArgumentNullException("Visa"); } return(await this.insuranceRespository.UpdateAsync(record)); } catch (Exception ex) { throw ex; } }
//Business Logics for Life Insurance private bool RecordNewLifeInsurance(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage) { ValidateAddInsurance validation = new ValidateAddInsurance(); bool isCorrectAge = validation.ValidateForAge(client.Age); bool isClientAdded = _repository.Create(client); if (isClientAdded) { bool isInsuranceAdded = _repository.Create(insurance); if (isInsuranceAdded) { bool isDocumentAdded = _repository.Create(document); if (isDocumentAdded) { bool isCoverageAdded = _repository.Create(coverage); if (isCoverageAdded) { bool isPolicyCoverageAdded = _repository.Create(policyCoverage); if (isPolicyCoverageAdded) { return(_repository.Save()); } else { return(false); } } else { return(false); } } else { return(false); } } else { return(false); } } else { return(false); } }
public HttpResponseMessage AddInsurance([FromBody] ApiInsuranceModel insurance) { //Mapping Api Models to Common Models APIModelMapper mapper = new APIModelMapper(); InsuranceModel selectedInsurance = mapper.MapInsuranceTypeModel(insurance.InsuranceType, insurance, insurance.SelectedInsurance); ClientModel client = mapper.MapClientModel(insurance.Client); PolicyCoverageDetailModel policyCoverage = mapper.MapPolicyCoverageDetailModel(insurance.PolicyDetails); DocumentModel document = mapper.MapDocumentModel(insurance.Documents); CoverageModel coverage = mapper.MapCoverage(insurance.Coverage); if (_insuranceManager.Record(selectedInsurance, client, policyCoverage, document, coverage)) { return(new HttpResponseMessage(HttpStatusCode.OK)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public ApiInsuranceModel Get(String insuranceId) { /* ApiInsuranceModel insurance = new ApiInsuranceModel * { * //ID = (int)ID, * //AgentID = 1, * //ClientID = 1, * //Joining_Date = new DateTime(2000, 02, 29), * //End_Date = new DateTime(2017, 02, 29), * //Total_Value = 1000000, * }; * * return insurance;*/ InsuranceModel selectedInsurance = _insuranceManager.Find <InsuranceModel>(e => e.ID.Equals(insuranceId)); ClientModel clientModel = _insuranceManager.Find <ClientModel>(e => e.ID.Equals(selectedInsurance.ID)); DocumentModel document = _insuranceManager.Find <DocumentModel>(e => e.InsuranceID.Equals(selectedInsurance.ID)); PolicyCoverageDetailModel pcd = _insuranceManager.Find <PolicyCoverageDetailModel>(e => e.InsuranceID.Equals(selectedInsurance.ID)); CoverageModel coverage = _insuranceManager.Find <CoverageModel>(e => e.ID.Equals(pcd.CoverageID)); CommonToApiModelMapper mapper = new CommonToApiModelMapper(); ApiInsuranceModel mapped = new ApiInsuranceModel(); if (selectedInsurance.InsuranceType.Equals(InsuranceModel.InsuranceTypes.LIFE_INSURANCE)) { LifeInsuranceModel life = _insuranceManager.Find <LifeInsuranceModel>(e => e.ClientID.Equals(selectedInsurance.ClientID)); ApiLifeInsuranceModel apiLifeInsuranceModel = mapper.MapLifeInsuranceCommonModel(life); mapped.SelectedInsurance = apiLifeInsuranceModel; } ApiClientModel apiCLient = mapper.MapClientCommonModel(clientModel); ApiDocumentModel apiDoc = mapper.MapDocumentCommonModel(document); ApiPolicyCoverageDetailModel apiPcd = mapper.MapPolicyCoverageDetailCommonModel(pcd); ApiCoverageModel apiCoverage = mapper.MapCoverageCommonModel(coverage); mapped.Client = apiCLient; mapped.Coverage = apiCoverage; mapped.Documents = apiDoc; mapped.PolicyDetails = apiPcd; return(mapped); }
/// <summary> /// Convert the Insurance DB entity to Model /// </summary> /// <param name="insAgencies"></param> /// <returns></returns> private List <InsuranceModel> ConvertToInsModel(List <tblInsuranceAgency> insAgencies) { List <InsuranceModel> models = new List <InsuranceModel>(); foreach (var i in insAgencies) { InsuranceModel model = new InsuranceModel() { InsuranceId = i.INSURANCEID, InsuranceName = i.INSAGENCYNAME, Description = i.DESCRIPTION, InsuranceFax = i.INSURANCEFAX, InsurancePhone = i.INSURANCEPHONE, Instructions = i.INSTRUCTIONS, PreAuthRequired = i.PREAUTHREQUIRED.HasValue ? i.PREAUTHREQUIRED.Value : false, HasOwnPaperWork = i.HASOWNPAPEROWORK.HasValue ? i.HASOWNPAPEROWORK.Value : false, CreatedBy = i.CREATEDBY, CreatedOn = i.CREATEDON }; models.Add(model); } return(models); }
public bool CreateInsurance(InsuranceModel model) { Insurance newInsurance = new Insurance { AnnualCoverageLimit = model.AnnualCoverageLimit, UnlimitedAnnualCoverageLimit = model.UnlimitedAnnualCoverageLimit, DeductibleAmount = model.DeductibleAmount, EndDateTime = model.EndDateTime, PaymentAmount = model.PaymentAmount, Company = model.Company, PolicyId = model.PolicyId?.Value, ReimbursementPercentage = model.ReimbursementPercentage, RenewalDateTime = model.RenewalDateTime, StartDateTime = model.StartDateTime, Website = model.Website, Created = model.Created, Modified = model.Modified, Deleted = model.Deleted }; newInsurance.PaymentFrequency = !model.PaymentFrequencyDays.HasValue ? null : new TimeSpan(model.PaymentFrequencyDays.Value, 0, 0, 0); using (ISession session = NHibernateSession.OpenSession()) { Dog foundDog = session.Query <Dog>().FirstOrDefault(u => u.DogId == model.Dog.DogId.Value); if (foundDog == null) { return(false); } newInsurance.Dog = foundDog; using (ITransaction transaction = session.BeginTransaction()) // Begin a transaction { session.Save(newInsurance); // Save the user in session transaction.Commit(); // Commit the changes to the database } } return(true); }
public bool UpdateInsurance(InsuranceModel model) { try { using (ISession session = NHibernateSession.OpenSession()) { Insurance foundInsurance = session.Query <Insurance>().FirstOrDefault(c => c.InsuranceId == model.InsuranceId.Value); if (foundInsurance == null) { return(false); } foundInsurance.Modified = DateTime.UtcNow; foundInsurance.UnlimitedAnnualCoverageLimit = model.UnlimitedAnnualCoverageLimit; foundInsurance.AnnualCoverageLimit = model.AnnualCoverageLimit; foundInsurance.DeductibleAmount = model.DeductibleAmount; foundInsurance.EndDateTime = model.EndDateTime; foundInsurance.PaymentAmount = model.PaymentAmount; foundInsurance.PaymentFrequency = !model.PaymentFrequencyDays.HasValue ? null : new TimeSpan(model.PaymentFrequencyDays.Value, 0, 0, 0); foundInsurance.Company = model.Company; foundInsurance.PolicyId = model.PolicyId?.Value; foundInsurance.ReimbursementPercentage = model.ReimbursementPercentage; foundInsurance.RenewalDateTime = model.RenewalDateTime; foundInsurance.StartDateTime = model.StartDateTime; foundInsurance.Website = model.Website; using (ITransaction transaction = session.BeginTransaction()) // Begin a transaction { session.Update(foundInsurance); // Save the user in session transaction.Commit(); // Commit the changes to the database } } } catch (Exception ex) { } return(true); }
public async Task <ActionResult> Add(InsuranceModel model) { try { if (ModelState.IsValid) { Insurance insur = new Insurance(); insur.Name = model.Name; await _context.Insurances.AddAsync(insur); await _context.SaveChangesAsync(); } else { TempData["message"] = ModelState.ErrorGathering(); } return(RedirectToAction(nameof(Index))); } catch (Exception ex) { TempData["message"] = ex.Message; return(RedirectToAction(nameof(Index))); } }
public static async Task <string> InvokeRequestResponseService(InsuranceModel model) { using (var client = new HttpClient()) { var scoreRequest = new { Inputs = new Dictionary <string, List <Dictionary <string, string> > >() { { "input1", new List <Dictionary <string, string> >() { new Dictionary <string, string>() { { "age", model.age.ToString() }, { "sex", model.sex.ToString() }, { "bmi", model.bmi.ToString() }, { "children", model.children.ToString() }, { "smoker", model.smoker.ToString() }, { "region", model.region.ToString() }, { "charges", model.charges.ToString() }, } } }, }, GlobalParameters = new Dictionary <string, string>() { } }; const string apiKey = "WN7bsC1N3+/HjqSgVoviUIzAf+zo7HcTTnw37QblIDl321BXuElhK1Cu6VKtghvOw3dQLiybJZqVyx62obBNLw=="; // Replace this with the API key for the web service client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); client.BaseAddress = new Uri("https://ussouthcentral.services.azureml.net/workspaces/7e089a9ec28140138cdaf6f17fe1b0c8/services/918e313f56554573a27952c971b433b6/execute?api-version=2.0&format=swagger"); string result = string.Empty; try { HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsStringAsync(); } else { Console.WriteLine(string.Format("The request failed with status code: {0}", response.StatusCode)); Console.WriteLine(response.Headers.ToString()); result = await response.Content.ReadAsStringAsync(); } } catch (Exception e) { var ex = e; } return(result); } }
public async Task <string> Post(InsuranceModel model) { var result = await CallRequestResponseService.InvokeRequestResponseService(model); return(result.ToString()); }
public static bool Save(IServerAuthentication restClientAuthenticator, InsuranceModel model) { return(ApiClientGenericObject <InsuranceModel> .Save(restClientAuthenticator, ControllerName, model)); }
public InsuranceCreateRequest() { Insurance = new InsuranceModel(); }
/// <summary> /// Gets the insurance agency details /// </summary> /// <param name="insAgencyId"></param> /// <returns></returns> public ActionResult GetInsuranceAgencyDetails(int insAgencyId) { InsuranceModel model = GetInsuranceFromDB(insAgencyId);//new InsuranceModel(); return(View(model)); }
public ActionResult Index(int startYear, int endYear, int cob, int losstype) { try { //List<TypeOfLoss> rowsToShow; var orgId = LookUps.GetOrgId(User.Identity.Name); if (orgId == 0) { orgId = Settings.Default.DefaultOrgId; } var growthCurveData = _unitOfWork.DevFactorRepository.Get( filter: x => x.OrgID == orgId && x.FactorName.Equals("Growth Curve", StringComparison.CurrentCultureIgnoreCase)) .ToList(); var chartCategory = growthCurveData.Select(a => a.DevPeriod.ToString()).ToList(); var chartData = growthCurveData.Select(x => x.FactorValue).Cast <object>().ToList(); var chart = new DotNet.Highcharts.Highcharts("chart") .InitChart(new Chart { Type = ChartTypes.Areaspline }) .SetTitle(new Title { Text = "Growth Curve" }) .SetXAxis(new XAxis { Categories = chartCategory.ToArray(), }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Growth Curve Value" } }) .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.x +': '+ this.y +' units'; }" }) .SetCredits(new Credits { Enabled = false }) .SetPlotOptions(new PlotOptions { Areaspline = new PlotOptionsAreaspline { FillOpacity = 0.5 } }) .SetSeries(new Series { Name = "Dev Period", Data = new Data(chartData.ToArray()), // Color = ColorTranslator.FromHtml("#89A54E"), }); var model = new InsuranceModel() { OrgId = orgId, Cob = cob, LossType = losstype, //LinkRatioData = _unitOfWork.PaidDataRepository.GetResultReport("LinkRatioView", // new SqlParameter("@orgId", SqlDbType.Int) { Value = orgId }, // new SqlParameter("@cob", SqlDbType.Int) { Value = cob }, // new SqlParameter("@losstype", SqlDbType.Int) { Value = losstype }), ModelData = _unitOfWork.PaidDataRepository.GetResultReport("rModelView", orgId, cob, losstype), ModelCummulativeData = _unitOfWork.PaidDataRepository.GetResultReport("rModelCummulativeView", orgId, cob, losstype), LinkRatioData = _unitOfWork.PaidDataRepository.GetResultReport("LinkRatioView", orgId, cob, losstype), DevFactor = _unitOfWork.PaidDataRepository.GetResultReport("DevFactView", orgId, cob, losstype), CurrentRatio = _unitOfWork.PaidDataRepository.GetResultReport("CurrentRatioView", orgId, cob, losstype), ProjectedData = _unitOfWork.PaidDataRepository.GetResultReport("rModelProjectedView", orgId, cob, losstype), UnwiddingData = _unitOfWork.PaidDataRepository.GetResultReport("rModelUnwiddingView", orgId, cob, losstype), ProjectedAmount = _unitOfWork.PaidDataRepository.GetResultReport("ProjectedAmountView", orgId, cob, losstype), TypeOfLoss = _unitOfWork.TypeOfLossRepository.GetByID(losstype), ClassOfBusiness = _unitOfWork.ClassOfBusinessRepository.GetByID(cob), Organisation = _unitOfWork.OrganisationRepository.GetByID(orgId), StartYear = startYear, EndYear = endYear, GrowthCurveChart = chart }; return(View(model)); } catch (Exception ex) { // Log with Elmah ErrorSignal.FromCurrentContext().Raise(ex); TempData["message"] = Settings.Default.GenericExceptionMessage; return(RedirectToAction("Index", "Home", new { area = "Admin" })); } }
public ActionResult Add() { InsuranceModel model = new InsuranceModel(); return(View(model)); }