示例#1
0
 public static Role RetrieveRoleByID(long?roleID)
 {
     try
     {
         return(RoleDL.RetrieveRoleByID(roleID));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
        public static dynamic AuthenticateUser(string username, string password)
        {
            try
            {
                User user = UserDL.AuthenticateUser(username, password);
                if (user != null)
                {
                    dynamic userObj = new ExpandoObject();

                    List <dynamic> userFunctions = new List <dynamic>();

                    Role userRole = RoleDL.RetrieveRoleByID(user.UserRole);
                    foreach (RoleFunction roleFunction in userRole.RoleFunctions)
                    {
                        dynamic function = new
                        {
                            Name     = roleFunction.Function.Name,
                            PageLink = roleFunction.Function.PageLink
                        };

                        userFunctions.Add(function);
                    }

                    userObj.ID       = user.ID;
                    userObj.Username = user.Username;
                    userObj.Role     = userRole.Name;
                    userObj.Function = userFunctions;
                    userObj.BranchID = BranchDL.RetrieveBranchByID(user.UserBranch).ID;

                    return(userObj);
                }
                return(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }