Passwort setzen funktion

This commit is contained in:
Andre Beging
2022-05-20 07:47:38 +02:00
parent f80ba142bc
commit 21f4906277
9 changed files with 172 additions and 51 deletions

View File

@@ -104,6 +104,35 @@ namespace FoodsharingSiegen.Server.Data.Service
#endregion
#region Public Method SetPassword
/// <summary>
/// Sets the password using the specified user (a. beging, 20.05.2022)
/// </summary>
/// <param name="user">The user</param>
/// <returns>A task containing the operation result</returns>
public async Task<OperationResult> SetPassword(User user)
{
try
{
var entityUser = await Context.Users.FirstOrDefaultAsync(x => x.Id == user.Id);
if (entityUser == null) return new OperationResult(new Exception("User not found"));
entityUser.Password = user.Password;
var saveR = await Context.SaveChangesAsync();
if(saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern"));
return new OperationResult();
}
catch (Exception e)
{
return new OperationResult(e);
}
}
#endregion
#region Public Method Update
/// <summary>
@@ -134,7 +163,7 @@ namespace FoodsharingSiegen.Server.Data.Service
var saveR = await Context.SaveChangesAsync();
if(saveR < 1) return new OperationResult(new Exception("Fehler beim speichern"));
if(saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern"));
return new OperationResult();
}
catch (Exception e)