Ejemplo n.º 1
0
        public IHttpActionResult PutUserAccounts(UpdateAccountDTO updateAccount)        // UPDATE USER ACCOUNT
        {
            TextResult httpResponse = new TextResult("Account has been updated!", msg); // Http response

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            UserAccountsManager umgr           = new UserAccountsManager();
            UserAccounts        updatedUserAcc = umgr.UpdateAccountDetails(updateAccount); // Function to update account details

            if (updatedUserAcc is null)
            {
                httpResponse.ChangeHTTPMessage("Failed to update account!", msg); // Http response if user entity is null
                return(httpResponse);
            }
            bool entityIsUpdated = umgr.UpdateEntityInDb(updatedUserAcc); // Updating entity in DB

            if (entityIsUpdated.Equals(true))
            {
                return(httpResponse);
            }

            httpResponse.ChangeHTTPMessage("Failed to update account!", msg);
            return(httpResponse);
        }