public IHttpActionResult PutInsurer(int id, Insurer insurer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != insurer.InsurerID) { return(BadRequest()); } db.Entry(insurer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!InsurerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(Insurer insurer, Address address, string[] Uphones) { if (ModelState.IsValid) { if (Uphones != null) { foreach (string n in Uphones) { var phone = new Phone(); var data = n.Split('|'); phone.number = data[0]; phone.type = (int)GlobalHelpers.ParseEnum <PhoneTypes>(data[1]); phone.notes = data[2]; db.Phones.Add(phone); insurer.Phones.Add(phone); } } insurer.createdBy = WebSecurity.CurrentUserId; insurer.status = true; insurer.Address = address; db.Insurers.Add(insurer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(insurer)); }
private void FormLoad(object sender, RoutedEventArgs e) { Insurer <string> insurer = new Insurer <string> { LegalAddress = TextAdres.Text, MailingAddress = TextPostalAdres.Text, PhoneFax = TextPhoneAndFacs.Text, INNAndKPP = TextINNAndKPP.Text, PaymentAccount = TextPaymentAccount.Text, Bank = TextBank.Text, CorrespondentAccount = TextCorrespondentAccount.Text, BIC = TextBIC.Text, EMALL = TextEmail.Text }; XDocument xdocload = XDocument.Load("settingCompany.xml"); XElement root = xdocload.Element("settingCompany"); foreach (XElement x in root.Elements("Company").ToList()) { TextCompanyName.Text = x.Attribute("CompanyName").Value; TextAdres.Text = x.Element("LegalAddress").Value; TextPostalAdres.Text = x.Element("MailingAddress").Value; TextPhoneAndFacs.Text = x.Element("PhoneFax").Value; TextINNAndKPP.Text = x.Element("INNAndKPP").Value; TextPaymentAccount.Text = x.Element("PaymentAccount").Value; TextBank.Text = x.Element("Bank").Value; TextCorrespondentAccount.Text = x.Element("CorrespondentAccount").Value; TextBIC.Text = x.Element("BIC").Value; TextEmail.Text = x.Element("EMALL").Value; } }
public IActionResult UpdateInsurer(int id, [FromBody] UpdateInsurerViewModel viewModel) { Insurer _insurer = _insurerService.Get(id); if (_insurer is null) { return(NotFound()); } if (ModelState.IsValid) { // Atualizar _insurer.Name = viewModel.Name; _insurer.Phone = viewModel.Phone; _insurer.Email = viewModel.Email; //Address _insurer.CEP = viewModel.CEP; _insurer.Street = viewModel.Street; _insurer.Number = viewModel.Number; _insurer.Neighborhood = viewModel.Neighborhood; _insurer.City = viewModel.City; _insurer.UF = viewModel.UF; return(Ok(_insurerService.Update(_insurer))); } else { return(BadRequest()); } }
public IActionResult CreateDriver([FromBody] CreateInsurerViewModel viewModel) { try { if (ModelState.IsValid) { Insurer _broker = new Insurer() { Name = viewModel.Name, CNPJ = viewModel.CNPJ, Phone = viewModel.Phone, Email = viewModel.Email, CEP = viewModel.CEP, Street = viewModel.Street, Number = viewModel.Number, Neighborhood = viewModel.Neighborhood, City = viewModel.City, UF = viewModel.UF }; return(Created("", _insurerService.Insert(_broker))); } else { return(BadRequest()); } } catch (Exception ex) { return(BadRequest(ex.InnerException)); } }
public async Task <IActionResult> Edit(Insurer insurer) { if (ModelState.IsValid) { UpdateInsurerViewModel viewModel = new UpdateInsurerViewModel() { Phone = insurer.Phone, Name = insurer.Name, Email = insurer.Email, CEP = insurer.CEP, Street = insurer.Street, Neighborhood = insurer.Neighborhood, UF = insurer.UF, City = insurer.City, Number = insurer.Number }; if (await _movtechAPIService.AtualizarSeguradora(insurer.Id, viewModel)) { return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "Não Foi possível Atualizar a Corretora"); return(View(insurer)); } } else { return(View(insurer)); } }
public async Task <IActionResult> Edit(InsurerViewModel viewModel) { if (ModelState.IsValid) { try { Insurer insurer = new Insurer(); insurer = viewModel.Insurer; _context.Update(insurer); await _context.SaveChangesAsync(); var payeeParams = new object[] { insurer.ID, insurer.Name }; await _context.Database.ExecuteSqlCommandAsync( "UPDATE Payee SET Name = {0} WHERE PayeeItemID = {1}", parameters : payeeParams); return(RedirectToAction("Index", new { payeeclassId = viewModel.Insurer.PayeeClassID })); } catch (DbUpdateException ex) { var errorMsg = ex.InnerException.Message.ToString(); viewModel.ErrMsg = errorMsg; ModelState.AddModelError(string.Empty, viewModel.ErrMsg); } } return(View(viewModel)); }
public ActionResult DeleteConfirmed(int id) { Insurer insurer = db.Insurers.Find(id); insurer.Phones.Clear(); db.Insurers.Remove(insurer); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Details(int id = 0) { Insurer insurer = db.Insurers.Find(id); if (insurer == null) { return(this.InvokeHttp404(HttpContext)); } return(View(insurer)); }
public IActionResult Delete(Insurer ins) { var insurerToDelete = db.Insurers.FirstOrDefault(i => i.Id == ins.Id); var accountToDelete = db.ApplicationUsers.FirstOrDefault(u => u.Id == insurerToDelete.ApplicationUserId); db.Insurers.Remove(insurerToDelete); db.ApplicationUsers.Remove(accountToDelete); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult GetInsurer(int id) { Insurer insurer = db.Insurers.Find(id); if (insurer == null) { return(NotFound()); } return(Ok(insurer)); }
public ActionResult SaveInsurerDetail(int?id) { getNoOfReferralAccordingToProcessLevels(); Insurer objInsurerModel = new Insurer(); if (id != null) { //var _InsurerResult = _iPaticipantService.getInsurerByID(id.Value); objInsurerModel = Mapper.Map <Insurer>(_iPaticipantService.getInsurerByID(id.Value)); } return(View(objInsurerModel)); }
public IHttpActionResult PostInsurer(Insurer insurer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Insurers.Add(insurer); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = insurer.InsurerID }, insurer)); }
public async Task <IHttpActionResult> Add([FromBody] InsurerModel model) { if (model.LogoId == null) { ModelState.AddModelError("logoId", "Logo is required"); } if (!ModelState.IsValid) { return(JsonError(HttpStatusCode.BadRequest, 10, "Warning", ModelState)); } using (var unitOfWork = UnitOfWork.Create()) { var userId = User.Identity.GetUserId(); var file = unitOfWork.FileRepository.GetAll().FirstOrDefault(f => f.Id == model.LogoId); if (file == null) { return(JsonError(HttpStatusCode.BadRequest, 10, "File doesn't exist.", ModelState)); } unitOfWork.BeginTransaction(); SaveFileAsLogo(unitOfWork, file); var insurer = new Insurer(); insurer.Name = model.Name; insurer.URL = model.URL; insurer.Phone = model.Phone; insurer.PhoneOverseas = model.PhoneOverseas; insurer.LogoFileId = model.LogoId; insurer.Email = model.Email; insurer.Color = model.Color; insurer.CreatedById = userId; insurer.CreatedDate = DateTime.Now; insurer.Status = InsurerStatus.Active; insurer.Description = model.Description; unitOfWork.InsurerRepository.Insert(insurer); await unitOfWork.SaveAsync(); unitOfWork.CommitTransaction(); var insurerResult = new { id = insurer.Id }; return(Json(insurerResult)); } }
public IActionResult GetInsurer(int id) { Insurer _insurer = _insurerService.Get(id); if (_insurer != null) { return(Ok(_insurer)); } else { return(NotFound()); } }
public ActionResult AddInsurer(Insurer objInsurer) { try { objInsurer.InsurerId = _insurerBL.AddInsurerRecord(Mapper.Map <LMGEDI.Core.Data.Model.Insurer>(objInsurer)); return(Json(objInsurer, GlobalConst.ContentTypes.TextHtml)); } catch (Exception ex) { _arCommonService.CreateErrorLog(ex.Message, ex.StackTrace); return(View()); } }
public double CalculateOwnerRelatedRisksAndBonuses(InfoForInsurance info, Insurer insurer, double tariffNumber, Models.Models.InsurerRiskOrBonus irb, RiskOrBonus currentRisk) { switch (currentRisk.Nomenclature) { case "Owner age between 18 and 25": if (info.OwnerAge >= 18 && info.OwnerAge <= 25) { tariffNumber += irb.TariffNumberChange; } break; case "Owner age between 26 and 50": if (info.OwnerAge >= 26 && info.OwnerAge <= 50) { tariffNumber += irb.TariffNumberChange; } break; case "Owner age over 50": if (info.OwnerAge > 50) { tariffNumber += irb.TariffNumberChange; } break; case "New Customer": if (info.CarInsurerId != insurer.Id) { tariffNumber += irb.TariffNumberChange; } break; case "Customer has MTPL": if (info.MTPLInsurerId == insurer.Id) { tariffNumber += irb.TariffNumberChange; } break; case "Customer has car insurance": if (info.CarInsurerId == insurer.Id) { tariffNumber += irb.TariffNumberChange; } break; } return(tariffNumber); }
private CounterPart GetCounterPart() { CounterPart counterPart = new CounterPart(); try { XmlNode element = this.document.GetElementsByTagName("counterparts").Item(0); foreach (XmlNode item in element.ChildNodes) { if (item.Name == "transporter") { Transporter transporter = new Transporter(); foreach (XmlNode trans in item.ChildNodes) { if (trans.Name == "name") { transporter.Name = trans.InnerText; } else if (trans.Name == "text") { transporter.Text = trans.InnerText; } } counterPart.Transporter = transporter; } else if (item.Name == "insurer") { Insurer insurer = new Insurer(); foreach (XmlNode insere in item.ChildNodes) { if (insere.Name == "name") { insurer.Name = insere.InnerText; } else if (insere.Name == "text") { insurer.Text = insere.InnerText; } } counterPart.Insurer = insurer; } } } catch (Exception ex) { Console.WriteLine($"Произошла ошибка при парсинге элемента CounterParts."); throw ex; } return(counterPart); }
public async Task <IActionResult> Create(InsurerViewModel viewModel) { if (ModelState.IsValid) { Insurer insurer = new Insurer(); insurer = viewModel.Insurer; insurer.ID = Guid.NewGuid(); _context.Add(insurer); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { payeeclassId = viewModel.Insurer.PayeeClassID })); } return(View(viewModel)); }
public IHttpActionResult DeleteInsurer(int id) { Insurer insurer = db.Insurers.Find(id); if (insurer == null) { return(NotFound()); } db.Insurers.Remove(insurer); db.SaveChanges(); return(Ok(insurer)); }
public ActionResult Edit(int id = 0) { Insurer insurer = db.Insurers.Find(id); if (insurer == null) { return(this.InvokeHttp404(HttpContext)); } InsurerViewModel model = new InsurerViewModel(); GlobalHelpers.Transfer <Insurer, InsurerViewModel>(insurer, model); return(View(model)); }
// GET: Insurers/Create public IActionResult Create(int payeeClassId) { Insurer insurer = new Insurer { PayeeClassID = payeeClassId }; InsurerViewModel viewModel = new InsurerViewModel { Insurer = insurer }; return(View(viewModel)); }
public async Task <Notifiable> Handle(CreateInsurerCommand request, CancellationToken cancellationToken) { var exists = await _repository.ExistsByName(request.Name); if (exists) { return(new Notifiable(new NotifiableError($"A seguradora '{request.Name}' já está cadastrada"))); } var insurer = new Insurer(request.Name); await _repository.Add(insurer); await _repository.Save(); return(new Notifiable("Seguradora cadastrada com sucesso", insurer)); }
public async Task <Notifiable> Handle(UpdateInsurerCommand request, CancellationToken cancellationToken) { var exists = await _repository.Exists(x => x.Id == request.Id); if (!exists) { return(new Notifiable(new NotifiableError("A seguradora informada não está cadastrada"))); } var updated = new Insurer(request.Id, request.Name); _repository.Update(updated); await _repository.Save(); return(new Notifiable("Seguradora cadastrada com sucesso", updated)); }
public IActionResult CreateDriver([FromBody] CreateInsurenceViewModel viewModel) { try { if (ModelState.IsValid) { Vehicle _vehicle = _vehicleService.Get(viewModel.VehicleId); Broker _broker = _brokerService.Get(viewModel.BrokerId); Insurer _insurer = _insurerService.Get(viewModel.InsurerId); Insurence _insurence = new Insurence() { BeginOfVigency = viewModel.BeginOfVigency, EndOfVigency = viewModel.EndOfVigency, BonusClass = viewModel.BonusClass, CINumber = viewModel.CINumber, PolicyNumber = viewModel.PolicyNumber, Vehicle = _vehicle, Broker = _broker, Insurer = _insurer, }; _insurenceService.Insert(_insurence); if (_vehicleService.SetInsurence(_insurence, viewModel.VehicleId)) { return(Created("", _insurence)); } else { return(BadRequest()); } } else { return(BadRequest()); } } catch (Exception ex) { return(BadRequest(ex.InnerException)); } }
public void addInsurer() { Insurer _Insurer = new Insurer { InsName = "vLastName2", InsPhone = "2135649872", InsAddress1 = "AdjAddress1", InsAddress2 = "AdjAddress2", InsFax = "2135469872", InsEMail = "*****@*****.**", InsZip = "90024", InsCity = "AdjCity2", InsStateId = 1 }; var _id = _insurerRepository.addInsurer(_Insurer); Assert.IsTrue(_id > 0, "failed"); }
public bool InsurerCreate(InsurerCreate model) { var entity = new Insurer() { Name = model.Name, Email = model.Email, Address = model.Address, PhoneNumber = model.PhoneNumber, Type = (Data.InsurerTypes)model.Type }; using (var ctx = new ApplicationDbContext()) { ctx.Insurers.Add(entity); return(ctx.SaveChanges() == 1); } }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as EnrollmentRequest; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.FinancialResourceStatusCodes>)StatusElement.DeepCopy(); } if (CreatedElement != null) { dest.CreatedElement = (Hl7.Fhir.Model.FhirDateTime)CreatedElement.DeepCopy(); } if (Insurer != null) { dest.Insurer = (Hl7.Fhir.Model.ResourceReference)Insurer.DeepCopy(); } if (Provider != null) { dest.Provider = (Hl7.Fhir.Model.ResourceReference)Provider.DeepCopy(); } if (Organization != null) { dest.Organization = (Hl7.Fhir.Model.ResourceReference)Organization.DeepCopy(); } if (Subject != null) { dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy(); } if (Coverage != null) { dest.Coverage = (Hl7.Fhir.Model.ResourceReference)Coverage.DeepCopy(); } return(dest); }
public IActionResult Edit(Insurer insurer) { var insurerToEdit = db.Insurers.FirstOrDefault(i => i.Id == insurer.Id); //var user = db.ApplicationUsers.FirstOrDefault(u => u.Id == insurer.ApplicationUserId); var userInfo = db.ApplicationUsers.FirstOrDefault(u => u.Id == insurerToEdit.ApplicationUserId); if (User.IsInRole("Insurer")) { if (insurer.MaximumDiscount != 0) { insurerToEdit.Name = insurer.Name; insurerToEdit.MaximumDiscount = insurer.MaximumDiscount; userInfo.Email = insurer.ApplicationUser.Email; userInfo.PhoneNumber = insurer.ApplicationUser.PhoneNumber; db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "Maximum discount cannot be 0"); } } else { if (insurer.Name != null) { insurerToEdit.Name = insurer.Name; userInfo.Email = insurer.ApplicationUser.Email; userInfo.PhoneNumber = insurer.ApplicationUser.PhoneNumber; db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "Name is required!"); } } return(View(insurerToEdit)); }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; if (model.PhoneNumber != null) { user.PhoneNumber = model.PhoneNumber; } var insurer = new Insurer(); var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { insurer.Name = model.InsuranceCompanyName; insurer.ApplicationUser = user; db.Insurers.Add(insurer); db.SaveChanges(); _logger.LogInformation("User created a new account with password."); await _userManager.AddToRoleAsync(user, "Insurer"); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); // await _signInManager.SignInAsync(user, isPersistent: false); _logger.LogInformation("User created a new account with password."); return(RedirectToLocal(returnUrl)); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
private ServiceCarInsuranceQuoteRequest BuildServiceRequest(Insurer insurer, int quoteId, CarQuoteRequestDto request, VehicleDetailsDto vehicle) { return new ServiceCarInsuranceQuoteRequest { QuoteRequestId = quoteId, NoClaimsDiscountYears = request.NoClaimsDiscountYears.HasValue ? request.NoClaimsDiscountYears.Value : 0, VehicleValue = request.VehicleValue.HasValue ? request.VehicleValue.Value : 0, CurrentRegistration = vehicle.CurrentRegistration, DriverAge = request.DriverAge.HasValue ? request.DriverAge.Value : 0, ModelDesc = vehicle.ModelDesc, IsImport = vehicle.IsImport, ManufYear = vehicle.ManufYear.HasValue ? vehicle.ManufYear.Value : 0, Insurer = insurer }; }