protected internal bool Insert(string userName, string password)
        {
            try
            {
                AuthenticationLibrary.Model.User obj = new AuthenticationLibrary.Model.User();
                obj.UserName = userName;
                obj.Password = password;

                OE.Users.Add(obj);
                OE.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public bool Insert(AuthenticationLibrary.Model.User user, AuthenticationLibrary.Model.Role role)
 {
     try
     {
         if (user != null && role != null)
         {
             DLL.UserRole userRole = new DLL.UserRole();
             return(userRole.Insert(user, role));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #3
0
        protected internal bool Insert(AuthenticationLibrary.Model.User user, AuthenticationLibrary.Model.Role role)
        {
            try
            {
                AuthenticationLibrary.Model.UserRole obj = new AuthenticationLibrary.Model.UserRole();
                obj.Role = new AuthenticationLibrary.Model.Role {
                    RoleId = role.RoleId, RoleName = role.RoleName
                };
                obj.User = new AuthenticationLibrary.Model.User {
                    UserId = user.UserId, Password = user.Password, UserName = user.UserName
                };

                OE.UserRoles.Add(obj);
                OE.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #4
0
        protected internal string[] GetUserRoles(string userName)
        {
            try
            {
                AuthenticationLibrary.Model.User user = OE.Users.Where(x => x.UserName == userName).FirstOrDefault();
                if (user != null)
                {
                    var rolesList = new List <string>();
                    foreach (var userRole in user.UserRoles)
                    {
                        rolesList.Add(userRole.RoleId.ToString());
                    }

                    String   listString  = String.Join(", ", rolesList);
                    string[] rolesString = listString.Split(',');
                    return(rolesString);
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }