// public async Task <IActionResult> SaveInsurer(InsurerVM insurerVM) { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var orgId = _context.Users.Where(x => x.Id == userId).FirstOrDefault().OrganisationId; InsurerMaster insurerMaster = new InsurerMaster(); insurerMaster.Id = Guid.NewGuid(); insurerMaster.Address = insurerVM.insurerMaster.Address; insurerMaster.Commission = insurerVM.insurerMaster.Commission; insurerMaster.DateCreated = DateTime.Now; insurerMaster.DateModified = DateTime.Now; insurerMaster.DateUpdated = DateTime.Now; insurerMaster.Description = insurerVM.insurerMaster.Description; insurerMaster.DisplayName = insurerVM.insurerMaster.DisplayName; insurerMaster.Email = insurerVM.insurerMaster.Email; insurerMaster.GlobalInsurerId = Guid.Empty; insurerMaster.Name = insurerVM.insurerMaster.Name; insurerMaster.IsDeleted = false; insurerMaster.OrganisationId = orgId; insurerMaster.PhoneNo = insurerVM.insurerMaster.PhoneNo; insurerMaster.WebUrl = insurerVM.insurerMaster.WebUrl; _context.Add(insurerMaster); await _context.SaveChangesAsync(); StatusMessage = StaticContent.INSURER_CREAT_MESSAGE; ViewData["StatusMessage"] = StatusMessage; return(RedirectToAction("Index")); }
public async Task <IActionResult> GetInsurerById(Guid?id) { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var orgId = _context.Users.Where(x => x.Id == userId).FirstOrDefault().OrganisationId; InsurerMaster insurerMaster = await _context.InsurerMasters.Where(i => i.Id == id).FirstOrDefaultAsync(); insurerMaster.NewRecord = "edit"; return(PartialView("InsurerPartialView", insurerMaster)); }
public async Task CreateInsurerMaster(InsurersDto input) { var Newinsurer = new InsurerMaster(input.InsurerName, input.Mask, input.LogoPicture, input.Id, input.CountryID); int InsurerNewId = await _insurersRepository.InsertAndGetIdAsync(Newinsurer); byte[] byteArray = GetByteArray(input.LogoPicture); var NewPicForInsurer = new InsurerPics(byteArray, InsurerNewId); await _binaryObjectRepository.InsertAsync(NewPicForInsurer); }
public async Task <IActionResult> postNewInsurer([FromBody] PostNewInsurer postNewInsurer) { if (postNewInsurer == null) { return(Json(new { msg = "No Data" } )); } var orgId = getOrg(); var organisationDetails = await _context.Organisations.Where(x => x.Id == orgId).FirstOrDefaultAsync(); int noOfEmployee = _context.Users.Where(x => x.OrganisationId == orgId).Count(); try { InsurerMaster newInsure = new InsurerMaster() { Id = Guid.NewGuid(), GlobalInsurerId = Guid.NewGuid(), Name = postNewInsurer.Name, DisplayName = postNewInsurer.DisplayName, PhoneNo = postNewInsurer.PhoneNo, Email = postNewInsurer.Email, Address = postNewInsurer.Address, WebUrl = postNewInsurer.WebUrl, Description = postNewInsurer.Description, OrganisationId = orgId }; _context.Add(newInsure); _context.SaveChanges(); return(Json(new { msg = "Success" } )); } catch (Exception ee) { } return(Json( new { msg = "Fail" })); }
public async Task <IActionResult> EditInsurer(InsurerMaster insMaster) { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var orgId = _context.Users.Where(x => x.Id == userId).FirstOrDefault().OrganisationId; InsurerMaster insurerMaster = await _context.InsurerMasters.Where(i => i.Id == insMaster.Id).FirstOrDefaultAsync(); insurerMaster.Address = insMaster.Address; insurerMaster.Commission = insMaster.Commission; insurerMaster.Description = insMaster.Description; insurerMaster.DisplayName = insMaster.DisplayName; insurerMaster.Email = insMaster.Email; insurerMaster.Name = insMaster.Name; insurerMaster.PhoneNo = insMaster.PhoneNo; insurerMaster.WebUrl = insMaster.WebUrl; _context.Update(insurerMaster); await _context.SaveChangesAsync(); StatusMessage = StaticContent.INSURER_Edit_MESSAGE; ViewData["StatusMessage"] = StatusMessage; return(PartialView("Index")); }
public JsonResult CheckInsurerExist([FromBody] InsurerMaster im) { if (im.NewRecord == "new") { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var orgId = _context.Users.Where(x => x.Id == userId).FirstOrDefault().OrganisationId; im.OrganisationId = orgId; } InsurerMaster data = _context.InsurerMasters.Where(i => i.OrganisationId == im.OrganisationId && i.Name == im.Name.Trim()).FirstOrDefault(); if (data == null) { return(Json("notexist")); } else { if (im.Id == Guid.Empty) { return(Json("exist")); } else { if (data.Id == im.Id) { return(Json("notexist")); } else { return(Json("exist")); } } } return(Json("exist")); }
public void VerifyDefaultData(string countrycode) { int CountryID = _countries.FirstOrDefault(x => x.Code == countrycode).Id; string[] defaults = new string[] { "OTHER", "NONE" }; string defaultlogo = "default-profile-picture.png"; // Verify Bank foreach (var data in defaults) { var bank = _Banks.FirstOrDefault(c => c.BankName == data && c.CountryID == CountryID); // If not exist for current country, then add banknames "OTHER" and "NONE" to tblbanks with countryid and enable if (bank == null) { var client = new Banks() { BankName = data, CountryID = CountryID, isActive = true }; _Banks.Insert(client); } else // Enable Bank if not { bank.isActive = true; _Banks.Update(bank); } // Verify Insurer var insurer = _insurer.FirstOrDefault(c => c.InsurerName == data && c.CountryID == CountryID); // If not exist for current country, then add InsurerName "OTHER" and "NONE" to tblinsurerMaster with countryid and enable if (insurer == null) { var client = new InsurerMaster() { InsurerName = data, CountryID = CountryID, LogoPicture = defaultlogo, Mask = data, IsActive = true }; int Id = _insurer.InsertAndGetId(client); var logo = new InsurerPics() { Bytes = GetBytes(defaultlogo), InsurerID = Id, }; _insurerpic.Insert(logo); } else // Enable Bank if not { insurer.IsActive = true; _insurer.Update(insurer); } // Verify Broker var broker = _broker.FirstOrDefault(c => c.BrokerName == data && c.CountryID == CountryID); // If not exist for current country, then add brokerName "OTHER" and "NONE" to tblBrokerMaster with countryid and enable if (broker == null) { var client = new BrokerMaster() { BrokerName = data, CountryID = CountryID, LogoPicture = defaultlogo, Mask = data, IsActive = true }; int id = _broker.InsertAndGetId(client); var logobroker = new BrokerMasterPics() { Bytes = GetBytes(defaultlogo), BrokerID = id }; _brokerpic.Insert(logobroker); } else // Enable Bank if not { broker.IsActive = true; _broker.Update(broker); } //Default Vendors var vendor = _vendors.FirstOrDefault(c => c.SupplierName == data && c.CountryID == CountryID); // If not exist for current country, then add SupplierName "OTHER" and "NONE" to tblVendorMain with countryid and enable if (vendor == null) { var client = new VendorMain() { SupplierCode = Guid.NewGuid(), SupplierName = data, CountryID = CountryID }; _vendors.Insert(client); } //Default Towoperator var tow = _tow.FirstOrDefault(c => c.Description == data && c.CountryID == CountryID); // If not exist for current country, then add Description "OTHER" and "NONE" to tblTowOperator with countryid and enable if (tow == null) { var client = new TowOperator() { Description = data, CountryID = CountryID, isActive = true }; _tow.Insert(client); } } }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var orgId = Guid.NewGuid(); Organisation newOrganisation = new Organisation() { Id = orgId, OrganisationId = orgId, OrganisationName = model.OrganisationName }; var user = new ApplicationUser { UserName = model.Email, Email = model.Email, OrganisationId = newOrganisation.Id, OrganisationName = model.OrganisationName, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, UserRole = "Super Admin" }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await _userManager.AddToRoleAsync(user, "Super Admin"); //Create Organisation profile immediately a new user come on board via the registration page. newOrganisation.RegistrarId = Guid.Parse(user.Id); _context.Add(newOrganisation); _context.SaveChanges(); Branch branch = new Branch() { Id = Guid.NewGuid(), BranchName = "Headquarters", OrganisationId = newOrganisation.Id, }; _context.Add(branch); _context.SaveChanges(); Department dept = new Department() { DepartmentName = "Admin", OrganisationId = newOrganisation.Id, Description = "Default", Id = Guid.NewGuid(), }; _context.Add(dept); _context.SaveChanges(); JobTitle jt = new JobTitle() { Id = Guid.NewGuid(), JobTitleName = "Admin", Description = "Default", OrganisationId = newOrganisation.Id, }; _context.Add(jt); _context.SaveChanges(); EmployeeDetail employeeDetail = new EmployeeDetail() { FirstName = model.FirstName, LastName = model.LastName, OrganisationId = newOrganisation.Id, UserId = newOrganisation.RegistrarId, Email = model.Email, }; _context.Add(employeeDetail); _context.SaveChanges(); Job jb = new Job() { Id = Guid.NewGuid(), DepartmentId = dept.Id, JobTitleId = jt.Id, EmployeeDetailId = employeeDetail.Id, }; _context.Add(jb); _context.SaveChanges(); _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); await _emailSender.SendGridEmailConfrimationAsync(model.Email, "Confirmation", callbackUrl, model.FirstName); try { //get global insurer data from the database var giList = _context.GlobalInsurers.ToList(); foreach (var insurer in giList) { var insurerMaster = new InsurerMaster(); insurerMaster.Id = new Guid(); insurerMaster.GlobalInsurerId = insurer.Id; insurerMaster.OrganisationId = newOrganisation.Id; insurerMaster.Name = insurer.Name; insurerMaster.PhoneNo = insurer.PhoneNo; insurerMaster.WebUrl = insurer.WebUrl; insurerMaster.Address = insurer.Address; insurerMaster.Commission = insurer.Commission; insurerMaster.Description = insurer.Description; insurerMaster.DisplayName = insurer.DisplayName; insurerMaster.Email = insurer.Email; insurerMaster.DateCreated = DateTime.Now; insurerMaster.DateModified = DateTime.Now; insurerMaster.DateUpdated = DateTime.Now; _context.Add(insurerMaster); _context.SaveChanges(); } } catch (Exception ex) { } try { /////// //add configuration for the new user var configList = _context.LeadConfigOptions.ToList(); foreach (var config in configList) { var configoption = new BussinessOperationConfiguration(); configoption.Id = new Guid(); configoption.Key = config.Key; configoption.Value = config.Value; configoption.OrganisationId = newOrganisation.Id; configoption.DateCreated = DateTime.Now; configoption.DateModified = DateTime.Now; configoption.DateUpdated = DateTime.Now; configoption.IsDeleted = false; _context.Add(configoption); _context.SaveChanges(); } }catch (Exception ex) { } // await _signInManager.SignInAsync(user, isPersistent : false); _logger.LogInformation("User created a new account with password."); StatusMessage = "Account created. Kindly update organisation details. Thanks."; return(RedirectToLocal(returnUrl)); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }