Edit prospect

This commit is contained in:
Andre Beging
2022-04-11 17:21:55 +02:00
parent 434426bd7c
commit dfb8040866
6 changed files with 198 additions and 33 deletions

View File

@@ -55,21 +55,6 @@ namespace FoodsharingSiegen.Server.Data.Service
#endregion
public async Task<OperationResult> RemoveInteraction(Guid interactionId)
{
try
{
Context.Interactions.Remove(new Interaction { Id = interactionId });
await Context.SaveChangesAsync();
return new OperationResult();
}
catch (Exception e)
{
return new OperationResult(e);
}
}
#region Public Method AddProspectAsync
/// <summary>
@@ -122,5 +107,60 @@ namespace FoodsharingSiegen.Server.Data.Service
}
#endregion
#region Public Method RemoveInteraction
/// <summary>
/// Removes the interaction using the specified interaction id (a. beging, 11.04.2022)
/// </summary>
/// <param name="interactionId">The interaction id</param>
/// <returns>A task containing the operation result</returns>
public async Task<OperationResult> RemoveInteraction(Guid interactionId)
{
try
{
Context.Interactions.Remove(new Interaction { Id = interactionId });
await Context.SaveChangesAsync();
return new OperationResult();
}
catch (Exception e)
{
return new OperationResult(e);
}
}
#endregion
#region Public Method UpdateAsync
/// <summary>
/// Updates the prospect (a. beging, 11.04.2022)
/// </summary>
/// <param name="prospect">The prospect</param>
/// <returns>A task containing the operation result</returns>
public async Task<OperationResult> UpdateAsync(Prospect prospect)
{
try
{
var entityProspect = await Context.Prospects.FirstOrDefaultAsync(x => x.Id == prospect.Id);
if (entityProspect == null) return new OperationResult(new Exception("Prospect not found"));
entityProspect.Memo = prospect.Memo;
entityProspect.Name = prospect.Name;
entityProspect.FsId = prospect.FsId;
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
}
}