Пример #1
0
        //Handle individual profile processes
        #region
        public async Task <bool> ValidateIndividualProfile(IndividualProfileViewModel model)
        {
            response = await client.GetAsync("api.bankmodel/customerservice/individual-profile-exist/" + model);

            if (Convert.ToBoolean(response.Content.ReadAsStringAsync().Result) == true)
            {
                _validationDictionary.AddError("", string.Format(_config.GetSection("Messages")["ObjectExist"], string.Concat(model.Title, " ", model.Lastname, ", ", model.Othernames)));
            }

            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);
        }
Пример #2
0
        public IActionResult IndividualProfile()
        {
            var model = new IndividualProfileViewModel {
                StatusMessage = StatusMessage
            };

            SetIndividualProfileViewItems();
            return(View(model));
        }
        public async Task <IActionResult> UpdateIndividualProfile(IndividualProfileViewModel model)
        {
            var result = await _customerServiceRepository.UpdateIndividualProfileAsync(model);

            if (result == "Succeeded")
            {
                return(Ok());
            }
            return(BadRequest(result));
        }
        public async Task <string> UpdateIndividualProfileAsync(IndividualProfileViewModel model)
        {
            try
            {
                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.Lastname        = model.Lastname.ToUpper();
                profile.Othernames      = model.Othernames.ToUpper();
                profile.CustomerType    = model.CustomerType.ToUpper();
                profile.ContactAddress  = model.ContactAddress.ToUpper();
                profile.DateOfBirth     = model.DateOfBirth;
                profile.Designation     = model.Designation.ToUpper();
                profile.Employer        = model.Employer.ToUpper();
                profile.EmployerAddress = model.EmployerAddress.ToUpper();
                profile.Email           = email.ToUpper();
                profile.Gender          = model.Gender;
                profile.Nationality     = model.Nationality;
                profile.StateOfOrigin   = model.StateOfOrigin;
                profile.LGA             = model.LGA;
                profile.HomeTown        = model.HomeTown.ToUpper();
                profile.MaritalStatus   = model.MaritalStatus;
                profile.NextOfKin       = model.NextofKin.ToUpper();
                profile.NokAddress      = model.NoKAddress.ToUpper();
                profile.NoKPhoneNumber  = model.NoKPhoneNumber;
                profile.NokRelationship = model.NoKRelationship.ToUpper();
                profile.Sector          = model.Sector;
                profile.ProfileImage    = profile.ID;
                profile.PhoneNumber     = model.PhoneNumber;
                profile.Title           = model.Title;
                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"); }
        }
Пример #5
0
        public async Task <bool> CreateIndividualProfileAsync(IndividualProfileViewModel model)
        {
            var result = await ValidateIndividualProfile(model);

            if (!result)
            {
                return(false);
            }

            string profileModel = JsonConvert.SerializeObject(model);
            var    contentData  = new StringContent(profileModel, System.Text.Encoding.UTF8, "application/json");

            response = client.PostAsync("api.bankmodel/customerservice/create-individual-profile", contentData).Result;
            return(response.StatusCode == System.Net.HttpStatusCode.OK ? true : false);
        }
Пример #6
0
        public IActionResult UpdateIndividualProfile(IndividualProfileViewModel model)
        {
            //If here, then its individual profile update
            Result = await _customerService.UpdateCustomerAccountAsync(model);

            if (Result.Equals("Succeeded"))
            {
                StatusMessage = _config.GetSection("Messages")["Success"];
                SetCustomerAccountViewItems();
                return(RedirectToAction(nameof(CustomerAccountListing)));
            }
            else
            {
                model = new CustomerAccountViewModel {
                    StatusMessage = "Error: Unable to update account"
                };
                SetCustomerAccountViewItems();
                return(View(model));
            }
        }
 public IActionResult CheckIfProfileExist(IndividualProfileViewModel model)
 {
     return(Ok(_customerServiceRepository.CheckIfProfileExist(model.Lastname, model.Othernames, model.DateOfBirth)));
 }
        public async Task <string> CreateIndividualProfileAsync(IndividualProfileViewModel model)
        {
            try
            {
                //This generates customer number for the user
                string customerNo = GenerateCustomerNo("INDIVIDUAL_CUSTOMER_PREFIX");
                generatedCustomerNo = customerNo;
                string email = string.Empty;

                if (model.Email == null)
                {
                    email = string.Empty;
                }
                else
                {
                    email = model.Email;
                }

                Branch branch = new Branch();
                //Determine if the request is from Super admin who has no profile
                if (model.Branch == null)
                {
                    if (model.ActionBy == _config.GetSection("AppInfo")["AdminUsername"])
                    {
                        branch = _context.Branch.Where(b => b.BranchCode == "00").FirstOrDefault();
                    }

                    branch = _context.ApplicationUser.Where(u => u.UserName == model.ActionBy)
                             .Include(b => b.Profile.Branch)
                             .Select(b => b.Profile.Branch)
                             .FirstOrDefault();
                }
                else
                {
                    branch = _context.Branch.Where(b => b.BranchDesc == model.Branch).FirstOrDefault();
                }

                Profile profile = new Profile
                {
                    ID              = customerNo,
                    Lastname        = model.Lastname.ToUpper(),
                    Othernames      = model.Othernames.ToUpper(),
                    ContactAddress  = model.ContactAddress.ToUpper(),
                    CustomerType    = model.CustomerType.ToUpper(),
                    Branch          = branch,
                    DateOfBirth     = model.DateOfBirth,
                    Designation     = model.Designation.ToUpper(),
                    Employer        = model.Employer.ToUpper(),
                    Email           = email.ToUpper(),
                    EmployerAddress = model.EmployerAddress.ToUpper(),
                    Gender          = model.Gender,
                    Nationality     = model.Nationality,
                    StateOfOrigin   = model.StateOfOrigin,
                    LGA             = model.LGA,
                    HomeTown        = model.HomeTown.ToUpper(),
                    MaritalStatus   = model.MaritalStatus,
                    NextOfKin       = model.NextofKin.ToUpper(),
                    NokAddress      = model.NoKAddress.ToUpper(),
                    NoKPhoneNumber  = model.NoKPhoneNumber,
                    NokRelationship = model.NoKRelationship.ToUpper(),
                    PhoneNumber     = model.PhoneNumber,
                    ProfileImage    = customerNo + ".jpg",
                    Sector          = model.Sector,
                    Title           = model.Title,
                    PostedBy        = model.ActionBy.ToUpper(),
                    TransDate       = GetTransactionDate(),
                    ApprovedBy      = string.Empty,
                    Status          = "PENDING",
                };

                _context.Profile.Add(profile);
                await _context.SaveChangesAsync();

                return("Succeeded");
            }
            catch { return("Falied"); }
        }
Пример #9
0
        public async Task <IActionResult> IndividualProfile(IndividualProfileViewModel model)
        {
            var user = await _userManager.GetUserAsync(User);

            if (!ModelState.IsValid)
            {
                model = new IndividualProfileViewModel {
                    StatusMessage = "Please correct the errors"
                };
                SetIndividualProfileViewItems();
                return(View(model));
            }

            if (!string.IsNullOrEmpty(model.ID))
            {
                var updateRequirementResult = _customerService.ValidateIndividualProfileRequirement(model);
                if (updateRequirementResult != null)
                {
                    foreach (var error in _validationDictionary.GetValidationErrors())
                    {
                        model = new IndividualProfileViewModel {
                            StatusMessage = error
                        };
                        SetIndividualProfileViewItems();
                        return(View(model));
                    }
                }

                //If here, then its individual profile update
                Result = await _customerService.UpdateIndividualProfileAsync(model);

                if (Result.Equals("Succeeded"))
                {
                    StatusMessage = _config.GetSection("Messages")["Success"];
                    return(RedirectToAction(nameof(IndividualProfileListing)));
                }
                else
                {
                    model = new IndividualProfileViewModel {
                        StatusMessage = "Error: Unable to update profile"
                    };
                    SetIndividualProfileViewItems();
                    return(View(model));
                }
            }

            var requirementResult = _customerService.ValidateIndividualProfileRequirement(model);

            if (requirementResult != null)
            {
                foreach (var error in _validationDictionary.GetValidationErrors())
                {
                    model = new IndividualProfileViewModel {
                        StatusMessage = error
                    };
                    SetIndividualProfileViewItems();
                    return(View(model));
                }
            }

            //If here, then its a new individual profile
            Result = await _customerService.CreateIndividualProfileAsync(model, user.UserName);

            if (Result.Equals("Succeeded"))
            {
                //This gets the generated Customer Number
                string customerNo = _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(IndividualProfile)));
            }
            else
            {
                model = new IndividualProfileViewModel {
                    StatusMessage = "Error: Unable to create individual profile"
                };
                SetIndividualProfileViewItems();
                return(View(model));
            }
        }