Passwort setzen funktion
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user