private void CreateSecurityRoleTableData()
 {
     foreach (string roleName in SecurityRoles.GetRoleList())
     {
         SecurityRole role = new SecurityRole();
         role.RoleName = roleName;
         SaveSecurityRole(role);
     }
 }
        public bool SignUp(EmployeeAccount employeeAccount)
        {
            if (employeeAccount != null)
            {
                if (!securityProvider.IsNidOrBirthRegNoExisi(employeeAccount.NidOrBirtgRegNo))
                {
                    if (!securityProvider.IsUserNameExisis(employeeAccount.UserName))
                    {
                        if (!securityProvider.IsEmailExist(employeeAccount.EmailAddress))
                        {
                            employeeAccount.AccountId      = CreateGuid();
                            employeeAccount.ConfirmationId = CatConfirmation.Yes;

                            db.EmployeeAccounts.Add(employeeAccount);
                            db.SaveChanges();


                            if (db.EmployeeAccounts.Count() == 1)
                            {
                                UserSecurityRole userRole = new UserSecurityRole();
                                userRole.UserAccountId   = employeeAccount.AccountId;
                                userRole.UserName        = employeeAccount.UserName;
                                userRole.Password        = employeeAccount.Password;
                                userRole.NidOrBirthRegNo = employeeAccount.NidOrBirtgRegNo;
                                userRole.EmailAddess     = employeeAccount.EmailAddress;
                                userRole.FirstName       = employeeAccount.FirstName;
                                userRole.LastName        = employeeAccount.LasttName;
                                userRole.RoleId          =
                                    (db.SecurityRoles.Where(r => r.RoleName == SecurityRoles.Admin).FirstOrDefault())
                                    .RoleId;

                                if (!securityProvider.IsUserSecurityRoleExist(userRole))
                                {
                                    UserSecurityRole adminRole = new UserSecurityRole();
                                    adminRole            = userRole;
                                    adminRole.UserRoleId = CreateGuid();
                                    db.UserSecurityRoles.Add(userRole);
                                    db.SaveChanges();
                                }
                            }

                            foreach (string role in SecurityRoles.GetRoleList())
                            {
                                SecurityRole securityRole = db.SecurityRoles.Where(r => r.RoleName == role).FirstOrDefault();
                                if (employeeAccount.EmployeeCatagoryId == securityRole.RoleId)
                                {
                                    UserSecurityRole employeeUserSecurityRoleRole = new UserSecurityRole();
                                    employeeUserSecurityRoleRole.UserRoleId      = CreateGuid();
                                    employeeUserSecurityRoleRole.UserAccountId   = employeeAccount.AccountId;
                                    employeeUserSecurityRoleRole.UserName        = employeeAccount.UserName;
                                    employeeUserSecurityRoleRole.Password        = employeeAccount.Password;
                                    employeeUserSecurityRoleRole.NidOrBirthRegNo = employeeAccount.NidOrBirtgRegNo;
                                    employeeUserSecurityRoleRole.EmailAddess     = employeeAccount.EmailAddress;
                                    employeeUserSecurityRoleRole.FirstName       = employeeAccount.FirstName;
                                    employeeUserSecurityRoleRole.LastName        = employeeAccount.LasttName;
                                    employeeUserSecurityRoleRole.RoleId          =
                                        (db.SecurityRoles.Where(r => r.RoleName == role).FirstOrDefault())
                                        .RoleId;

                                    if (!securityProvider.IsUserSecurityRoleExist(employeeUserSecurityRoleRole))
                                    {
                                        db.UserSecurityRoles.Add(employeeUserSecurityRoleRole);
                                        db.SaveChanges();
                                    }
                                }
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }