Edit prospect
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user