예제 #1
0
        /// <summary>
        /// This method is used to authenticate user if the user credentials exist int the database and it will return the same.
        /// </summary>
        /// <param name="login"></param>
        /// <returns></returns>

        public dynamic AuthenticateUser(Authenticate login)
        {
            if (login == null)
            {
                return(null);
            }
            try
            {
                Authenticate user = null;

                //Credentials obj = new Credentials();

                var ValidUsersDictionary = obj.GetCredentials();

                if (ValidUsersDictionary == null)
                {
                    return(null);
                }
                else
                {
                    if (ValidUsersDictionary.Any(u => u.Key == login.id && u.Value == login.Password))
                    {
                        user = new Authenticate {
                            id = login.id, Password = login.Password
                        };
                    }
                }

                return(user);
            }
            catch (Exception)
            {
                return(null);
            }
        }