//Handle corporate profile processes #region public async Task <bool> ValidateCorporateProfile(CorporateProfileViewModel model) { response = await client.GetAsync("api.bankmodel/customerservice/corporate-profile-exist/" + model); if (Convert.ToBoolean(response.Content.ReadAsStringAsync().Result) == true) { _validationDictionary.AddError("", string.Format(_config.GetSection("Messages")["ObjectExist"], model.CustomerName)); } response = await client.GetAsync("api.bankmodel/customerservice/phone-number-exist/" + model.PhoneNumber); if (Convert.ToBoolean(response.Content.ReadAsStringAsync().Result) == true) { _validationDictionary.AddError("", string.Format(_config.GetSection("Messages")["ObjectExist"], string.Concat("Phone number ", model.PhoneNumber))); } response = await client.GetAsync("api.bankmodel/customerservice/email-exist/" + model.Email); if (Convert.ToBoolean(response.Content.ReadAsStringAsync().Result) == true) { _validationDictionary.AddError("", string.Format(_config.GetSection("Messages")["ObjectExist"], string.Concat("Email address ", model.Email))); } return(_validationDictionary.IsValid); }
public async Task <string> UpdateCorporateProfileAsync(CorporateProfileViewModel model) { try { string website = string.Empty; if (model.Website == null) { website = string.Empty; } else { website = model.Website; } string email = string.Empty; if (model.Email == null) { email = string.Empty; } else { email = model.Email; } var profile = _context.Profile.Where(b => b.ID == model.ID).FirstOrDefault(); profile.ContactAddress = model.ContactAddress.ToUpper(); profile.CustomerBase = model.CustomerBase; profile.Lastname = model.CustomerName.ToUpper(); profile.CustomerType = model.CustomerType.ToUpper(); profile.DateOfBirth = model.DateOfIncorporation; profile.IncorporationType = model.IncorporationType.ToUpper(); profile.RCNo = model.RCNo.ToUpper(); profile.RegisteredBody = model.RegisteredBody.ToUpper(); profile.StartupCapital = model.StartupCapital; profile.Turnover = model.Turnover; profile.Website = website.ToUpper(); profile.NextOfKin = model.PrincipalOfficer.ToUpper(); profile.NokAddress = model.PrincipalOfficerAddress.ToUpper(); profile.NoKPhoneNumber = model.PrincipalOfficerPhoneNumber; profile.NokRelationship = model.PrincipalOfficerRelationship.ToUpper(); profile.Email = email.ToUpper(); profile.PhoneNumber = model.PhoneNumber; profile.Sector = model.BusinessSector; profile.ProfileImage = profile.ID; profile.PostedBy = model.ActionBy.ToUpper(); profile.TransDate = GetTransactionDate(); profile.ApprovedBy = string.Empty; profile.Status = "PENDING"; _context.Profile.Update(profile); await _context.SaveChangesAsync(); return("Succeeded"); } catch { return("Falied"); } }
public IActionResult CorporateProfile() { var model = new CorporateProfileViewModel { StatusMessage = StatusMessage }; SetCorporateProfileViewItems(); return(View(model)); }
public async Task <IActionResult> UpdateCorporateProfile(CorporateProfileViewModel model) { var result = await _customerServiceRepository.UpdateCorporateProfileAsync(model); if (result == "Succeeded") { return(Ok()); } return(BadRequest(result)); }
public async Task <bool> CreateCorporateProfileAsync(CorporateProfileViewModel model) { var result = await ValidateCorporateProfile(model); if (!result) { return(false); } string profileModel = JsonConvert.SerializeObject(model); var contentData = new StringContent(profileModel, System.Text.Encoding.UTF8, "application/json"); response = client.PutAsync("api.bankmodel/customerservice/update-corporate-profile", contentData).Result; return(response.StatusCode == System.Net.HttpStatusCode.OK ? true : false); }
public async Task <IActionResult> UpdateCorporateProfile(CorporateProfileViewModel model) { //If here, then its individual profile update Result = await _customerService.UpdateCorporateProfileAsync(model); if (Result) { StatusMessage = _config.GetSection("Messages")["Success"]; SetCustomerAccountViewItems(); return(RedirectToAction(nameof(CustomerAccountListing))); } model = new CorporateProfileViewModel { StatusMessage = "Error: Unable to update profile" }; SetCustomerAccountViewItems(); return(View(model)); }
public async Task <IActionResult> CorporateProfile(CorporateProfileViewModel model) { if (!ModelState.IsValid) { model = new CorporateProfileViewModel { StatusMessage = "Please correct the errors" }; SetCorporateProfileViewItems(); return(View(model)); } var user = await _userManager.GetUserAsync(User); //If here, then its a new individual profile model.ActionBy = user.UserName; Result = await _customerService.CreateCorporateProfileAsync(model); if (Result) { //This gets the generated Customer Number string customerNo = await _customerService.GetGeneratedCustomerNo(); var profileImageFileName = Path.Combine(_hostingEnvironment.WebRootPath, "assets/images/profile-images/" + customerNo + ".jpg"); using (var stream = new FileStream(profileImageFileName, FileMode.Create)) { model.ProfileImage.CopyTo(stream); } StatusMessage = _config.GetSection("Messages")["Success"]; return(RedirectToAction(nameof(CorporateProfile))); } model = new CorporateProfileViewModel { StatusMessage = "Error: Unable to create individual profile" }; SetCorporateProfileViewItems(); return(View(model)); }
public IActionResult CheckIfCorporateProfileExist(CorporateProfileViewModel model) { return(Ok(_customerServiceRepository.CheckIfProfileExist(model.CustomerName, model.DateOfIncorporation))); }
public async Task <string> CreateCorporateProfileAsync(CorporateProfileViewModel model) { try { //This generates customer number for the user #region string customerNo = string.Empty; string website = string.Empty; string email = string.Empty; var branch = _context.ApplicationUser.Where(u => u.UserName == model.ActionBy) .Include(b => b.Profile) .Select(b => b.Profile.Branch) .FirstOrDefault(); if (model.CustomerType == "CORPORATE") { customerNo = GenerateCustomerNo("CORPORATE_CUSTOMER_PREFIX"); } else if (model.CustomerType == "COOPERATIVE") { customerNo = GenerateCustomerNo("COOPERATIVE_CUSTOMER_PREFIX"); } generatedCustomerNo = customerNo; if (model.Website == null) { website = string.Empty; } else { website = model.Website; } if (model.Email == null) { email = string.Empty; } else { email = model.Email; } #endregion Profile profile = new Profile { ID = customerNo.ToUpper(), Branch = branch, ContactAddress = model.ContactAddress.ToUpper(), CustomerBase = model.CustomerBase, Lastname = model.CustomerName.ToUpper(), CustomerType = model.CustomerType.ToUpper(), DateOfBirth = model.DateOfIncorporation, IncorporationType = model.IncorporationType.ToUpper(), NextOfKin = model.PrincipalOfficer.ToUpper(), RCNo = model.RCNo.ToUpper(), RegisteredBody = model.RegisteredBody.ToUpper(), StartupCapital = model.StartupCapital, Turnover = model.Turnover, Website = website.ToUpper(), PhoneNumber = model.PhoneNumber, Email = email.ToUpper(), Sector = model.BusinessSector, NokAddress = model.PrincipalOfficerAddress.ToUpper(), NoKPhoneNumber = model.PrincipalOfficerPhoneNumber, NokRelationship = model.PrincipalOfficerRelationship.ToUpper(), ProfileImage = customerNo + ".jpg", PostedBy = model.ActionBy.ToUpper(), TransDate = GetTransactionDate(), ApprovedBy = string.Empty, Status = "PENDING" }; _context.Profile.Add(profile); await _context.SaveChangesAsync(); return("Succeeded"); } catch { return("Falied"); } }