diff options
author | crupest <crupest@outlook.com> | 2020-01-31 22:46:17 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-31 22:46:17 +0800 |
commit | 873d0d8df10e1d6403b7a4eac1980f874dfe1d05 (patch) | |
tree | f969a960472bbf828e5d639a8deef65341b52a6a /Timeline/Services/UserService.cs | |
parent | b892622e7ffdf4220f6631ec58f7a6692881dd35 (diff) | |
download | timeline-873d0d8df10e1d6403b7a4eac1980f874dfe1d05.tar.gz timeline-873d0d8df10e1d6403b7a4eac1980f874dfe1d05.tar.bz2 timeline-873d0d8df10e1d6403b7a4eac1980f874dfe1d05.zip |
Make all patch return the new entity.
Diffstat (limited to 'Timeline/Services/UserService.cs')
-rw-r--r-- | Timeline/Services/UserService.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Timeline/Services/UserService.cs b/Timeline/Services/UserService.cs index 93d92740..7dc7159d 100644 --- a/Timeline/Services/UserService.cs +++ b/Timeline/Services/UserService.cs @@ -82,6 +82,7 @@ namespace Timeline.Services /// </summary>
/// <param name="id">The id of the user.</param>
/// <param name="info">The new info. May be null.</param>
+ /// <returns>The new user info.</returns>
/// <exception cref="ArgumentException">Thrown when some fields in <paramref name="info"/> is bad.</exception>
/// <exception cref="UserNotExistException">Thrown when user with given id does not exist.</exception>
/// <remarks>
@@ -96,13 +97,14 @@ namespace Timeline.Services ///
/// </remarks>
/// <seealso cref="ModifyUser(string, User)"/>
- Task ModifyUser(long id, User? info);
+ Task<User> ModifyUser(long id, User? info);
/// <summary>
/// Modify a user's info.
/// </summary>
/// <param name="username">The username of the user.</param>
/// <param name="info">The new info. May be null.</param>
+ /// <returns>The new user info.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="username"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="username"/> is of bad format or some fields in <paramref name="info"/> is bad.</exception>
/// <exception cref="UserNotExistException">Thrown when user with given id does not exist.</exception>
@@ -120,7 +122,7 @@ namespace Timeline.Services /// Note: Whether <see cref="User.Version"/> is set or not, version will increase and not set to the specified value if there is one.
/// </remarks>
/// <seealso cref="ModifyUser(long, User)"/>
- Task ModifyUser(string username, User? info);
+ Task<User> ModifyUser(string username, User? info);
/// <summary>
/// Delete a user of given id.
@@ -370,7 +372,7 @@ namespace Timeline.Services }
- public async Task ModifyUser(long id, User? info)
+ public async Task<User> ModifyUser(long id, User? info)
{
ValidateModifyUserInfo(info);
@@ -382,9 +384,11 @@ namespace Timeline.Services await _databaseContext.SaveChangesAsync();
_logger.LogInformation(LogDatabaseUpdate, ("Id", id));
+
+ return CreateUserFromEntity(entity);
}
- public async Task ModifyUser(string username, User? info)
+ public async Task<User> ModifyUser(string username, User? info)
{
if (username == null)
throw new ArgumentNullException(nameof(username));
@@ -400,6 +404,8 @@ namespace Timeline.Services await _databaseContext.SaveChangesAsync();
_logger.LogInformation(LogDatabaseUpdate, ("Username", username));
+
+ return CreateUserFromEntity(entity);
}
public async Task<bool> DeleteUser(long id)
|