public HttpResponseMessage VerifyLogin(AuthenticationParameters model) { if (model == null)// Incase Post Object Is Null or Not Match and Object value is null { result = new ReponseMessage(MsgNo: HttpStatusCode.BadRequest.ToCode(), MsgType: MsgTypeEnum.E.ToString(), Message: "Object is null"); return(Request.CreateResponse(HttpStatusCode.BadRequest, result)); } if (ModelState.IsValid) { string password = AuthenticationServices.DecryptStringAES(model._SecretKey, model._password); model._password = password; List <AuthenticationDetailParameters> _AuthenticationDetailParameters = AuthenticationServices.GetAuthenticateUser(model); foreach (AuthenticationDetailParameters auth in _AuthenticationDetailParameters) { if (auth.status != "success") { result = new ReponseMessage(MsgNo: HttpStatusCode.Unauthorized.ToCode(), MsgType: MsgTypeEnum.E.ToString(), Message: auth.status, Validation: ModelState.AllErrors()); return(Request.CreateResponse(HttpStatusCode.Unauthorized, result)); } else { LoginResponse login = new LoginResponse(); string key = Utility.SecretkeyGenerator.CreateToken(auth.user_code, auth.password); login.user.Api_Key = key; login.user.UserCode = auth.user_code; login.user.privilege_name = auth.privilege_name; login.user.role_name = auth.role_name; login.user.UserName = auth.UserName; login.user.UserId = auth.user_id; model._token = key; int tokeupdated = AuthenticationServices.UpdateToken(model); // result = new ReponseMessage(KeyName: "api_key", Code: key, MsgNo: HttpStatusCode.OK.ToCode(), MsgType: MsgTypeEnum.S.ToString(), Message: "Success"); //Provided username and password is incorrect return(Request.CreateResponse(HttpStatusCode.OK, login)); } } return(Request.CreateResponse(HttpStatusCode.OK, _AuthenticationDetailParameters)); } else { result = new ReponseMessage(MsgNo: HttpStatusCode.BadRequest.ToCode(), MsgType: MsgTypeEnum.E.ToString(), Message: "", Validation: ModelState.AllErrors()); return(Request.CreateResponse(HttpStatusCode.BadRequest, result)); } return(null); }