Esempio n. 1
0
 public static void ConfigureAppModel(this ModelBuilder builder)
 {
     AppUserProfile.ConfigureFluent(builder);
     AppUserBank.ConfigureFluent(builder);
     AppUserRole.ConfigureFluent(builder);
     AppUserFile.ConfigureFluent(builder);
     Bank.ConfigureFluent(builder);
     Country.ConfigureFluent(builder);
     State.ConfigureFluent(builder);
     LGA.ConfigureFluent(builder);
     Staff.ConfigureFluent(builder);
     Supplier.ConfigureFluent(builder);
     BillPayable.ConfigureFluent(builder);
     BillReceivable.ConfigureFluent(builder);
     Journal.ConfigureFluent(builder);
     JournalLineItem.ConfigureFluent(builder);
     Payment.ConfigureFluent(builder);
     Receipt.ConfigureFluent(builder);
     PayableWorkFlow.ConfigureFluent(builder);
     ReceivableWorkFlow.ConfigureFluent(builder);
     AccountGroup.ConfigureFluent(builder);
     AccountSubType.ConfigureFluent(builder);
     LineItem.ConfigureFluent(builder);
     BankAccount.ConfigureFluent(builder);
     AppData.ConfigureFluent(builder);
 }
Esempio n. 2
0
        private async Task <AuthResponse> TryCreateUser(SignUpModel signUpModel, string errorMessage)
        {
            var response = default(AuthResponse);

            var appUserProfile = new AppUserProfile(signUpModel.FirstName, signUpModel.LastName, signUpModel.MarriageStatus, signUpModel.Gender, signUpModel.DateOfBirth);
            var user           = new AppUser(signUpModel.DisplayName, signUpModel.UserName, signUpModel.WorkerId, appUserProfile);
            var result         = await userManager.CreateAsync(user, signUpModel.Password);

            appUserProfile.AppUserId            = user.Id;
            context.Entry(appUserProfile).State = EntityState.Modified;
            context.SaveChanges();

            if (!result.Succeeded)
            {
                response = AuthResponseError.FromIdentityErrors(result.Errors, errorMessage);
            }
            else
            {
                result = await userManager.AddToRoleAsync(user, AuthRoles.User);

                if (!result.Succeeded)
                {
                    response = AuthResponseError.FromIdentityErrors(result.Errors, errorMessage);
                }
                else
                {
                    response = new AuthResponseOk("Sign up success. Sign in with your credentials");
                }
            }

            return(response);
        }
Esempio n. 3
0
        public IActionResult Confirmation()
        {
            var accountModel = HttpContext.Session
                               .GetObjectFromJson <AccountDetailView>("AccountDetailView");

            var userDetail     = accountModel?.UserDetail;
            var bankDetail     = accountModel?.BankDetail;
            var staffDetail    = accountModel?.StaffDetail;
            var supplierDetail = accountModel?.SupplierDetail;

            //AppUser Detail
            var appUser = new AppUser
            {
                //Username = userDetail.EmailAddress,
                //Password = "******",
                UserType = userDetail.UserType.ToString(),
                IsActive = true,
            };

            _unitOfWork.AppUsersRepository.Insert(appUser);

            //Profile Detail
            var appUserProfile = new AppUserProfile
            {
                FirstName    = userDetail.FirstName,
                LastName     = userDetail.LastName,
                MiddleName   = userDetail.MiddleName,
                Phone        = userDetail.Phone,
                EmailAddress = userDetail.EmailAddress,
                Website      = userDetail.Website,
                Address      = userDetail.Address,
                City         = userDetail.City,
                AppUser      = appUser,
            };

            _unitOfWork.AppUserProfilesRepository.Insert(appUserProfile);



            //Bank Detail
            if (bankDetail != null)
            {
                var appUserBank = new AppUserBank
                {
                    AccountName   = bankDetail.AccountName,
                    AccountNumber = bankDetail.AccountNumber,
                    BVN           = bankDetail.BVN,
                    TIN           = bankDetail.TIN,
                    AppUser       = appUser,
                };

                _unitOfWork.AppUserBanksRepository.Insert(appUserBank);
            }

            //Staff Detail
            if (staffDetail != null)
            {
                var staff = new Staff
                {
                    Title                = staffDetail.Title,
                    Rank                 = staffDetail.Rank,
                    GradeLevel           = staffDetail.GradeLevel,
                    DateOfFirstAppoint   = staffDetail.DateOfFirstAppoint,
                    DateOfCurrentAppoint = staffDetail.DateOfCurrentAppoint,
                    Notes                = staffDetail.Notes,
                    AppUser              = appUser,
                };

                _unitOfWork.StaffsRepository.Insert(staff);
            }

            //Supplier Detail
            if (supplierDetail != null)
            {
                var supplier = new Supplier
                {
                    CompanyName = supplierDetail.CompanyName,
                    ContactName = supplierDetail.ContactName,
                    Address     = supplierDetail.Address,
                    City        = supplierDetail.City,
                    Mobile      = supplierDetail.Mobile,
                    OfficePhone = supplierDetail.OfficePhone,
                    Email       = supplierDetail.Email,
                    Website     = supplierDetail.Website,
                    Notes       = supplierDetail.Notes,
                    AppUser     = appUser,
                };

                _unitOfWork.SuppliersRepository.Insert(supplier);
            }

            _unitOfWork.SaveChanges();


            return(View(accountModel));
        }