コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        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());
            }
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
ファイル: InsurersController.cs プロジェクト: levinkata/isas
        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));
        }
コード例 #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            Insurer insurer = db.Insurers.Find(id);

            insurer.Phones.Clear();
            db.Insurers.Remove(insurer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public ActionResult Details(int id = 0)
        {
            Insurer insurer = db.Insurers.Find(id);

            if (insurer == null)
            {
                return(this.InvokeHttp404(HttpContext));
            }
            return(View(insurer));
        }
コード例 #10
0
        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"));
        }
コード例 #11
0
        public IHttpActionResult GetInsurer(int id)
        {
            Insurer insurer = db.Insurers.Find(id);

            if (insurer == null)
            {
                return(NotFound());
            }

            return(Ok(insurer));
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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));
            }
        }
コード例 #15
0
        public IActionResult GetInsurer(int id)
        {
            Insurer _insurer = _insurerService.Get(id);

            if (_insurer != null)
            {
                return(Ok(_insurer));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #16
0
 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());
     }
 }
コード例 #17
0
        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);
        }
コード例 #18
0
ファイル: Parser.cs プロジェクト: osvinohradov/WSG_CRM
        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);
        }
コード例 #19
0
ファイル: InsurersController.cs プロジェクト: levinkata/isas
        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));
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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));
        }
コード例 #22
0
ファイル: InsurersController.cs プロジェクト: levinkata/isas
        // GET: Insurers/Create
        public IActionResult Create(int payeeClassId)
        {
            Insurer insurer = new Insurer
            {
                PayeeClassID = payeeClassId
            };

            InsurerViewModel viewModel = new InsurerViewModel
            {
                Insurer = insurer
            };

            return(View(viewModel));
        }
コード例 #23
0
        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));
        }
コード例 #24
0
        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));
        }
コード例 #25
0
        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));
            }
        }
コード例 #26
0
ファイル: InsurerTest.cs プロジェクト: buyonlinemahi/MMC
        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");
        }
コード例 #27
0
ファイル: InsurerService.cs プロジェクト: rstew33/DOICMS
        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);
            }
        }
コード例 #28
0
        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);
        }
コード例 #29
0
        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));
        }
コード例 #30
0
        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));
        }
コード例 #31
0
 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
     };
 }