public JsonStandardResponse Post([FromBody] userCredentialModel uCredential) { JsonStandardResponse result = null; try { DataAccessController controller = new DataAccessController(); result = new JsonStandardResponse { status = "success", data = controller.CreateUserCredential(uCredential).ToString(), message = "" }; } catch (Exception ex) { result = new JsonStandardResponse { status = "error", data = "", message = ex.Message }; new BusinessLogic().CreateLog(1, ex.Message, ex.HResult.ToString(), new Commons().BaseUrl + "createNewCredential/Post"); } return(result); }
public JsonStandardResponse Post(string userName, [FromBody] userCredentialModel uCreds) { JsonStandardResponse result = null; try { DataAccessController controller = new DataAccessController(); result = new JsonStandardResponse { status = "success", data = controller.UpdateUserCredentialsDetails(uCreds, userName), message = "" }; } catch (Exception ex) { result = new JsonStandardResponse { status = "error", data = "", message = ex.Message }; new BusinessLogic().CreateLog(1, ex.Message, ex.HResult.ToString(), "UpdateUserCredential/Post"); } return(result); }
public DataTable UpdateUserCredentialsDetails(userCredentialModel userCredentialsObj, string userName) { DataTable result = null; SqlConnection connection = null; string encryted = cryptoUtility.Encrypt(userCredentialsObj.password); try { connection = GetSQLConnection(); SqlCommand command = new SqlCommand("sp_UPDATE_CREDS", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@user", userName); command.Parameters.AddWithValue("@username", userCredentialsObj.userName); command.Parameters.AddWithValue("@password", encryted); int returnValue = command.ExecuteNonQuery(); if (returnValue > 0) { result = GetSingleUserDetails(userName); } } catch (Exception ex) { new BusinessLogic().CreateLog(1, ex.Message, ex.HResult.ToString(), "UpdateUserCredentialsDetails function in DataAccess Controller Class"); throw ex; } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } return(result); }