コード例 #1
0
ファイル: BankTable.cs プロジェクト: cleanqas/CETRA
        /// <summary>
        /// Inserts a new Bank in the Bank table
        /// </summary>
        /// <param name="bank">The Bank's detail</param>
        /// <returns></returns>
        public int Insert(IdentityBank bank)
        {
            string commandText = "Insert into banks (Id, BankName, BankAcronym) values (@id, @name, @acronym)";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@name", bank.Name);
            parameters.Add("@id", bank.Id);
            parameters.Add("@acronym", bank.Acronym);

            return(_database.Execute(commandText, parameters));
        }
コード例 #2
0
ファイル: BankTable.cs プロジェクト: cleanqas/CETRA
        /// <summary>
        /// Updates a Bank in the Bank table
        /// </summary>
        /// <param name="bank">The Bank's detail</param>
        /// <returns></returns>
        public int Update(IdentityBank bank)
        {
            string commandText = "Update banks set BankName = @name, BankAcronym = @acronym where Id = @id";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@name", bank.Name);
            parameters.Add("@id", bank.Id);
            parameters.Add("@acronym", bank.Acronym);

            return(_database.Execute(commandText, parameters));
        }
コード例 #3
0
ファイル: BankTable.cs プロジェクト: cleanqas/CETRA
        /// <summary>
        /// Gets the IdentityBank given the bank Id
        /// </summary>
        /// <param name="bankId"></param>
        /// <returns></returns>
        public IdentityBank GetBankById(string bankId)
        {
            var          bankDetail = GetBankName(bankId);
            IdentityBank bank       = null;

            if (bankDetail != null)
            {
                bank = new IdentityBank(bankDetail["BankName"], bankDetail["BankAcronym"], bankId);
            }

            return(bank);
        }
コード例 #4
0
        private void createRolesandUsers()
        {
            ApplicationDbContext context = new ApplicationDbContext();

            var roleManager   = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var UserManager   = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var branchManager = new BranchManager <IdentityBranch>(new BranchStore <IdentityBranch>(context));
            var bankManager   = new BankManager <IdentityBank>(new BankStore <IdentityBank>(context));

            var user = new ApplicationUser();

            //branchManager.CreateUploadStatus();
            if (!roleManager.RoleExists("Admin"))
            {
                var role = new AspNet.Identity.MySQL.IdentityRole();
                role.Name = "Admin";
                roleManager.Create(role);

                user.UserName = "******";
                user.Email    = "*****@*****.**";

                string userPWD = "password77$";

                var chkUser = UserManager.Create(user, userPWD);

                if (chkUser.Succeeded)
                {
                    var result1 = UserManager.AddToRole(user.Id, "Admin");
                }
            }

            if (!roleManager.RoleExists("BranchOperator"))
            {
                var role = new AspNet.Identity.MySQL.IdentityRole();
                role.Name = "BranchOperator";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("BranchVerifier"))
            {
                var role = new AspNet.Identity.MySQL.IdentityRole();
                role.Name = "BranchVerifier";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("HeadOfficeOperator"))
            {
                var role = new AspNet.Identity.MySQL.IdentityRole();
                role.Name = "HeadOfficeOperator";
                roleManager.Create(role);
            }

            if (!branchManager.BranchExists("Head Office"))
            {
                user = UserManager.FindByName("administrator");

                var bank = new AspNet.Identity.MySQL.IdentityBank();
                bank.Name = ConfigurationManager.AppSettings["OwnerBankName"];
                bankManager.Create(bank);

                var branch = new AspNet.Identity.MySQL.IdentityBranch();
                branch.Name       = "Head Office";
                branch.BranchCode = "HeadOffice";
                //branch.GLAccount = ConfigurationManager.AppSettings["DefaultGLAccount"];
                branchManager.Create(branch);
                branchManager.AddUserToBranch(user.Id, branch.Id);
                //branchManager.CreateUploadStatus();
            }
        }