コード例 #1
0
        public HttpResponseMessage LoginValidation(UserDetails loginparameters)
        {
            //Checking whether the object loginparameters is null
            if (loginparameters == null)
            {
                //If the loginparameters is null ArgumentNullException will be thrown

                throw new ArgumentNullException("NullValues");
            }

            //Passing the method <<CheckValidation>> in Business Layer and passing loginparameter which returns a bool value
            //The bool value is stored in res based upon which HttpResponseMessage will be returned

            bool res = userDetailsManager.CheckValidation(loginparameters);


            if (res)
            {
                //If the logincredentials are Valid, Statuscode"200" will be returned

                return(Request.CreateErrorResponse(HttpStatusCode.OK, "Logged in Sucessfully")); //using HttpError
            }
            else
            {
                //If the logincredentials are Invalid, Statuscode"401" will be returned

                return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Incorrect Credentials"));
            }
        }
コード例 #2
0
        public bool Validation(UserDetails user)
        {
            bool res = userDetailsManager.CheckValidation(user);

            return(res);
        }