public async Task <ResultObject> SetAsync([FromBody] UserDto userDto) { if (userDto.ID == 0) { return(await userAppService.CreateUserAsync(userDto)); } else { return(await userAppService.UpdateUserAsync(userDto)); } }
public async Task Test_CreateUser_IsUsernameExisted_UpdateUser_FindById() { var(target, dto) = CreateTargetAndDto(); var result = await target.CreateUserAsync(dto); Assert.IsNotNull(result); Assert.IsTrue(await target.IsUsernameExistedAsync(dto.Username, CancellationToken.None)); var dtoFound = await target.FindByIdAsync(dto.Id); await GeneralAssertAsync(dtoFound, target); result = await target.UpdateUserAsync(dto.Id, new UserItemDto { Avatar = "efg.png" }); Assert.IsNotNull(result); dtoFound = await target.FindByIdAsync(dto.Id); Assert.AreEqual("efg.png", dtoFound.Avatar); Assert.IsNotNull(dtoFound.Modified); }