public BaseResponse <GetAccountResponse> UpdateStatus(string accountId, UpdateAccountStatusRequest request) { var method = new HttpMethod("patch"); var endpoint = $"/accounts/{accountId}/status"; return(this.HttpClientUtil.SendRequest <GetAccountResponse>(method, endpoint, request, authMode: "amk")); }
public async Task UpdateUserAccountStatus_Success(int id, bool active) { var req = new UpdateAccountStatusRequest() { Id = id, Active = active, }; var service = new UserService(userMapper, userRepo); var result = await service.UpdateUserAccountStatus(req); result.ShouldBeTrue(); }
public async Task UpdateUserAccountStatus_Failure(int id, bool active) { var req = new UpdateAccountStatusRequest() { Id = id, Active = active, }; var service = new UserService(userMapper, userRepo); await Assert.ThrowsAsync <KeyNotFoundException>(async() => { var result = await service.UpdateUserAccountStatus(req); }); }
public async Task <bool> UpdateUserAccountStatus(UpdateAccountStatusRequest req) { var user = await _repo.GetAsync(req.Id); if (user == null) { throw new KeyNotFoundException($"Could not find user with id: {req.Id}"); } user.Active = req.Active; var updatedUser = _repo.Update(user); if (updatedUser == null) { return(false); } await _repo.UnitOfWork.SaveChangesAsync(); return(true); }