Ejemplo n.º 1
0
 public string GetUserRoles(string userName, string password)
 {
     using (RMSDbContext context = new RMSDbContext())
     {
         var roleName = context.USP_AuthenticateUser(userName, password).Select(s => s.RoleName).SingleOrDefault();
         return(roleName);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to verify user credentials in database
        /// </summary>
        /// <param name="userName">username</param>
        /// <param name="password">password</param>
        /// <returns></returns>
        public UserDetailsViewModel CheckUserCredentials(string userName, string password)
        {
            using (RMSDbContext context = new RMSDbContext())
            {
                var userDetails = context.USP_AuthenticateUser(userName, password).Select(
                    u => new UserDetailsViewModel()
                {
                    UserId             = u.UserId,
                    UserName           = u.UserName,
                    EmailId            = u.EmailId,
                    RoleName           = u.RoleName,
                    DisplayName        = u.DisplayName,
                    AuthorizationToken = CryptoHelper.Encrypt(String.Concat(userName, Constants.TOKEN_SEPARATOR, password), Constants.ENCRYPTION_KEY)
                }).SingleOrDefault();

                return(userDetails);
            }
        }