Beispiel #1
0
 public ApprovalRegRespObj CustomerTransactionEoD(CustomerTransactionObj item)
 {
     try
     {
         var update = UpdateCustomerBalanceForEoD(item.DebitAmount, item.CreditAmount, item.CasaAccountNumber, item.ReferenceNo, item.ValueDate.Value.Date);
         if (update == 0)
         {
             return(new ApprovalRegRespObj {
                 Status = new APIResponseStatus {
                     IsSuccessful = false, Message = new APIResponseMessage {
                         FriendlyMessage = "Account Balance Transaction could not update"
                     }
                 }
             });
         }
         var bal = _dataContext.credit_casa.Where(x => x.AccountNumber == item.CasaAccountNumber).FirstOrDefault().AvailableBalance;
         fin_customertransaction customerTrans = new fin_customertransaction
         {
             TransactionCode  = "TRANS-" + GeneralHelpers.GenerateRandomDigitCode(10),
             AccountNumber    = item.CasaAccountNumber,
             Description      = item.Description,
             TransactionDate  = item.TransactionDate,
             ValueDate        = item.ValueDate,
             TransactionType  = item.TransactionType,
             Amount           = item.CreditAmount == 0 ? item.DebitAmount : item.CreditAmount,
             CreditAmount     = item.CreditAmount,
             DebitAmount      = item.DebitAmount,
             AvailableBalance = bal,
             Beneficiary      = item.Beneficiary,
             BatchNo          = item.ReferenceNo
         };
         _dataContext.fin_customertransaction.Add(customerTrans);
         var response = _dataContext.SaveChanges() > 0;
         return(new ApprovalRegRespObj {
             Status = new APIResponseStatus {
                 IsSuccessful = true, Message = new APIResponseMessage {
                     FriendlyMessage = "Successful"
                 }
             }
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public async Task <int> AddUpdateCustomerAsync(DepositAccountOpeningObj entity)
        {
            try
            {
                if (entity == null)
                {
                    return(0);
                }
                int inserted_id = 0;
                deposit_accountopening CustomerExist = null;
                var accountNumber = GeneralHelpers.GenerateRandomDigitCode(10);

                if (entity.CustomerId > 0)
                {
                    CustomerExist = _dataContext.deposit_accountopening.Find(entity.CustomerId);
                    if (CustomerExist != null)
                    {
                        CustomerExist.AccountCategoryId     = entity.AccountCategoryId;
                        CustomerExist.AccountTypeId         = entity.AccountTypeId;
                        CustomerExist.CustomerTypeId        = entity.CustomerTypeId;
                        CustomerExist.AccountNumber         = entity.AccountNumber;
                        CustomerExist.Title                 = entity.Title;
                        CustomerExist.Surname               = entity.Surname;
                        CustomerExist.Firstname             = entity.Firstname;
                        CustomerExist.Othername             = entity.Othername;
                        CustomerExist.MaritalStatusId       = entity.MaritalStatusId;
                        CustomerExist.RelationshipOfficerId = entity.RelationshipOfficerId;
                        CustomerExist.GenderId              = entity.GenderId;
                        CustomerExist.BirthCountryId        = entity.BirthCountryId;
                        CustomerExist.DOB = entity.DOB;
                        CustomerExist.MotherMaidenName = entity.MotherMaidenName;
                        CustomerExist.TaxIDNumber      = entity.TaxIDNumber;
                        CustomerExist.BVN                  = entity.BVN;
                        CustomerExist.Nationality          = entity.Nationality;
                        CustomerExist.ResidentPermitNumber = entity.ResidentPermitNumber;
                        CustomerExist.PermitIssueDate      = entity.PermitIssueDate;
                        CustomerExist.PermitExpiryDate     = entity.PermitExpiryDate;
                        CustomerExist.SocialSecurityNumber = entity.SocialSecurityNumber;
                        CustomerExist.StateOfOrigin        = entity.StateOfOrigin;
                        CustomerExist.LocalGovernment      = entity.LocalGovernment;
                        CustomerExist.ResidentOfCountry    = entity.ResidentOfCountry;
                        CustomerExist.Address1             = entity.Address1;
                        CustomerExist.Address2             = entity.Address2;
                        CustomerExist.City                 = entity.City;
                        CustomerExist.StateId              = entity.StateId;
                        CustomerExist.CountryId            = entity.CountryId;
                        CustomerExist.Email                = entity.Email;
                        CustomerExist.MailingAddress       = entity.MailingAddress;
                        CustomerExist.MobileNumber         = entity.MobileNumber;
                        CustomerExist.InternetBanking      = entity.InternetBanking;
                        CustomerExist.EmailStatement       = entity.EmailStatement;
                        CustomerExist.Card                 = entity.Card;
                        CustomerExist.SmsAlert             = entity.SmsAlert;
                        CustomerExist.EmailAlert           = entity.EmailAlert;
                        CustomerExist.Token                = entity.Token;
                        CustomerExist.EmploymentType       = entity.EmploymentType;
                        CustomerExist.EmployerName         = entity.EmployerName;
                        CustomerExist.EmployerAddress      = entity.EmployerAddress;
                        CustomerExist.EmployerState        = entity.EmployerState;
                        CustomerExist.Occupation           = entity.Occupation;
                        CustomerExist.BusinessName         = entity.BusinessName;
                        CustomerExist.BusinessAddress      = entity.BusinessAddress;
                        CustomerExist.BusinessState        = entity.BusinessState;
                        CustomerExist.JobTitle             = entity.JobTitle;
                        CustomerExist.Other                = entity.Other;
                        CustomerExist.DeclarationDate      = entity.DeclarationDate;
                        CustomerExist.DeclarationCompleted = entity.DeclarationCompleted;
                        CustomerExist.SoleSignatory        = entity.SoleSignatory;
                        CustomerExist.MaxNoOfSignatory     = entity.MaxNoOfSignatory;
                        CustomerExist.RegistrationNumber   = entity.RegistrationNumber;
                        CustomerExist.Industry             = entity.Industry;
                        CustomerExist.Jurisdiction         = entity.Jurisdiction;
                        CustomerExist.Website              = entity.Website;
                        CustomerExist.NatureOfBusiness     = entity.NatureOfBusiness;
                        CustomerExist.AnnualRevenue        = entity.AnnualRevenue;
                        CustomerExist.IsStockExchange      = entity.IsStockExchange;
                        CustomerExist.Stock                = entity.Stock;
                        CustomerExist.RegisteredAddress    = entity.RegisteredAddress;
                        CustomerExist.ScumlNumber          = entity.ScumlNumber;
                        CustomerExist.UpdatedBy            = entity.CreatedBy;
                        CustomerExist.UpdatedOn            = DateTime.Now;
                    }
                }
                else
                {
                    CustomerExist = new deposit_accountopening
                    {
                        CustomerId            = entity.CustomerId,
                        AccountCategoryId     = entity.AccountCategoryId,
                        AccountTypeId         = entity.AccountTypeId,
                        CustomerTypeId        = entity.CustomerTypeId,
                        AccountNumber         = accountNumber,
                        Title                 = entity.Title,
                        Surname               = entity.Surname,
                        Firstname             = entity.Firstname,
                        Othername             = entity.Othername,
                        MaritalStatusId       = entity.MaritalStatusId,
                        RelationshipOfficerId = entity.RelationshipOfficerId,
                        GenderId              = entity.GenderId,
                        BirthCountryId        = entity.BirthCountryId,
                        DOB = entity.DOB,
                        MotherMaidenName = entity.MotherMaidenName,
                        TaxIDNumber      = entity.TaxIDNumber,
                        BVN                  = entity.BVN,
                        Nationality          = entity.Nationality,
                        ResidentPermitNumber = entity.ResidentPermitNumber,
                        PermitIssueDate      = entity.PermitIssueDate,
                        PermitExpiryDate     = entity.PermitExpiryDate,
                        SocialSecurityNumber = entity.SocialSecurityNumber,
                        StateOfOrigin        = entity.StateOfOrigin,
                        LocalGovernment      = entity.LocalGovernment,
                        ResidentOfCountry    = entity.ResidentOfCountry,
                        Address1             = entity.Address1,
                        Address2             = entity.Address2,
                        City                 = entity.City,
                        StateId              = entity.StateId,
                        CountryId            = entity.CountryId,
                        Email                = entity.Email,
                        MailingAddress       = entity.MailingAddress,
                        MobileNumber         = entity.MobileNumber,
                        InternetBanking      = entity.InternetBanking,
                        EmailStatement       = entity.EmailStatement,
                        Card                 = entity.Card,
                        SmsAlert             = entity.SmsAlert,
                        EmailAlert           = entity.EmailAlert,
                        Token                = entity.Token,
                        EmploymentType       = entity.EmploymentType,
                        EmployerName         = entity.EmployerName,
                        EmployerAddress      = entity.EmployerAddress,
                        EmployerState        = entity.EmployerState,
                        Occupation           = entity.Occupation,
                        BusinessName         = entity.BusinessName,
                        BusinessAddress      = entity.BusinessAddress,
                        BusinessState        = entity.BusinessState,
                        JobTitle             = entity.JobTitle,
                        Other                = entity.Other,
                        DeclarationDate      = entity.DeclarationDate,
                        DeclarationCompleted = entity.DeclarationCompleted,
                        SoleSignatory        = entity.SoleSignatory,
                        MaxNoOfSignatory     = entity.MaxNoOfSignatory,
                        RegistrationNumber   = entity.RegistrationNumber,
                        Industry             = entity.Industry,
                        Jurisdiction         = entity.Jurisdiction,
                        Website              = entity.Website,
                        NatureOfBusiness     = entity.NatureOfBusiness,
                        AnnualRevenue        = entity.AnnualRevenue,
                        IsStockExchange      = entity.IsStockExchange,
                        Stock                = entity.Stock,
                        RegisteredAddress    = entity.RegisteredAddress,
                        ScumlNumber          = entity.ScumlNumber,
                        Active               = true,
                        Deleted              = false,
                        CreatedBy            = entity.CreatedBy,
                        CreatedOn            = DateTime.Now,
                    };
                    _dataContext.deposit_accountopening.Add(CustomerExist);
                }
                using (var trans = _dataContext.Database.BeginTransaction())
                {
                    try
                    {
                        _dataContext.SaveChanges();
                        inserted_id = CustomerExist.CustomerId;
                        updateCASA(entity, inserted_id, accountNumber);
                        trans.Commit();
                        return(inserted_id);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw new Exception(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #3
0
        public async Task <AuthenticationResult> CustomerRegisterAsync(CustomUserRegistrationReqObj userRegistration)
        {
            try
            {
                var accountNumber = GeneralHelpers.GenerateRandomDigitCode(10);
                var existingUser  = await _userManager.FindByEmailAsync(userRegistration.Email);

                if (existingUser != null)
                {
                    return(new AuthenticationResult
                    {
                        Status = new APIResponseStatus
                        {
                            IsSuccessful = false,
                            Message = new APIResponseMessage
                            {
                                FriendlyMessage = "User with this email address already exist"
                            }
                        }
                    });
                }


                var user = new ApplicationUser
                {
                    Email            = userRegistration.Email,
                    UserName         = userRegistration.Email,
                    PhoneNumber      = userRegistration.PhoneNo,
                    FirstName        = userRegistration.FirstName,
                    LastName         = userRegistration.LastName,
                    Address          = userRegistration.Address,
                    CustomerTypeId   = userRegistration.CustomerTypeId,
                    ApprovalStatusId = 1,
                    SecurityAnswered = userRegistration.SecurityAnswered,
                    QuestionId       = userRegistration.QuestionId
                };

                var createdUser = await _userManager.CreateAsync(user, userRegistration.Password);

                var customer = new credit_loancustomer
                {
                    Email              = userRegistration.Email,
                    UserIdentity       = user.Id,
                    PhoneNo            = userRegistration.PhoneNo,
                    FirstName          = userRegistration.FirstName,
                    LastName           = userRegistration.LastName,
                    Address            = userRegistration.Address,
                    CustomerTypeId     = userRegistration.CustomerTypeId,
                    CASAAccountNumber  = accountNumber,
                    ApprovalStatusId   = 1,
                    ProfileStatus      = 0,
                    Active             = true,
                    Deleted            = false,
                    CreatedBy          = user.Email,
                    CreatedOn          = DateTime.Now,
                    RegistrationSource = "Website"
                };
                _dataContext.credit_loancustomer.Add(customer);
                _dataContext.SaveChanges();

                if (!createdUser.Succeeded)
                {
                    return(new AuthenticationResult
                    {
                        Status = new APIResponseStatus
                        {
                            IsSuccessful = false,
                            Message = new APIResponseMessage
                            {
                                FriendlyMessage = createdUser.Errors.Select(x => x.Description).FirstOrDefault(),
                            }
                        }
                    });
                }

                var custCode   = ConfirmationCode.Generate();
                var successful = await CustomerSendAndStoreConfirmationCode(custCode, user.Email);

                var accountId = user.Id;
                var name      = user.FirstName;
                var baseUrl   = _configuration.GetValue <string>("FrontEndUrl:webUrl");

                var url      = baseUrl + "/#/auth/activate-account/" + accountId + "";
                var content1 = "Welcome to GOS Credit! There's just one step before you get to complete your customer account registration. Verify you have the right email address by clicking on the button below.";
                var content2 = "Once your account creation is completed, your can explore our services and have a seamless experience.";
                var body     = GeneralHelpers.MailBody(name, url, content1, content2);

                var addresses = new ToAddress
                {
                    name    = user.FirstName + " " + user.LastName,
                    address = user.Email
                };
                var addressList = new List <ToAddress> {
                    addresses
                };
                var mailObj = new MailObj
                {
                    subject       = "Email Verification",
                    content       = body,
                    toAddresses   = addressList,
                    fromAddresses = new List <FromAddress> {
                    },
                    sendIt        = true,
                    saveIt        = false
                };

                var res = _identityServer.SendMail(mailObj);

                return(new AuthenticationResult
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = true,
                        CustomToken = custCode,
                    }
                });
            }
            catch (Exception ex)
            {
                #region Log error
                var errorCode = ErrorID.Generate(4);
                _logger.Error($"ErrorID :  {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new AuthenticationResult
                {
                    Status = new APIResponseStatus
                    {
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = "Error occured!! Please try again later",
                            MessageId = errorCode,
                            TechnicalMessage = $"ErrorID :  {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}"
                        }
                    }
                });

                #endregion
            }
        }