public AccountUpdateProfileModel UpdateProfile([FromBody] AccountUpdateProfileModel model, string token) { var session = IsTokenExpired(token); if (session != null) { var account = _readOnlyRepository.GetById <Account>(session.User.Id); //var updateAccount = _mappingEngine.Map<AccountUpdateProfileModel, Account>(model); account.FirstName = model.FirstName; account.LastName = model.LastName; account.UserName = model.UserName; account.Initials = model.Initials; account.Bio = model.Bio; var accountUpdated = _writeOnlyRepository.Update(account); var newAccount = new AccountUpdateProfileModel(); if (accountUpdated != null) { newAccount.FirstName = accountUpdated.FirstName; newAccount.LastName = accountUpdated.LastName; newAccount.Bio = accountUpdated.Bio; newAccount.Initials = accountUpdated.Initials; newAccount.UserName = accountUpdated.UserName; return(model); } //return new SuccessfulMessageResponse("Your profile was successfully updated"); } throw new BadRequestException("Your profile could not be updated"); }
public static bool IsAValidUpdate(AccountUpdateProfileModel model) { if (!IsAValidEmail(model.Email)) { throw new BadRequestException("The email is not valid"); } return(true); }
public static AccountUpdateProfileModel UpdateProfile(AccountUpdateProfileModel updateProfileModel, string token) { var client = new RestClient(BaseUrl); var request = InitRequest("/updateProfile/" + token, Method.PUT, updateProfileModel); IRestResponse <AccountUpdateProfileModel> response = client.Execute <AccountUpdateProfileModel>(request); return(response.Data); }