Update campaign handling
This commit is contained in:
@ -36,7 +36,7 @@ namespace Hcs.WebApp.Services
|
||||
{
|
||||
Type = type,
|
||||
InitiatorId = initiatorId,
|
||||
StartedAt = DateTime.UtcNow
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
await context.Campaigns.AddAsync(campaign);
|
||||
await context.SaveChangesAsync();
|
||||
@ -50,13 +50,51 @@ namespace Hcs.WebApp.Services
|
||||
{
|
||||
CampaignId = campaignId,
|
||||
Type = type,
|
||||
StartedAt = DateTime.UtcNow
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
await context.Operations.AddAsync(operation);
|
||||
await context.SaveChangesAsync();
|
||||
return operation;
|
||||
}
|
||||
|
||||
public async Task SetCampaignEndedWithFail(int campaignId, string failureReason)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
var campaign = await context.Campaigns.FirstOrDefaultAsync(x => x.Id == campaignId);
|
||||
if (campaign != null)
|
||||
{
|
||||
campaign.EndedAt = DateTime.UtcNow;
|
||||
campaign.FailureReason = failureReason;
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetOperationStarted(int operationId)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
var operation = await context.Operations.FirstOrDefaultAsync(x => x.Id == operationId);
|
||||
if (operation != null)
|
||||
{
|
||||
operation.StartedAt = DateTime.UtcNow;
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetOperationEndedWithFail(int operationId, string failureReason)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
var operation = await context.Operations.FirstOrDefaultAsync(x => x.Id == operationId);
|
||||
if (operation != null)
|
||||
{
|
||||
operation.EndedAt = DateTime.UtcNow;
|
||||
operation.FailureReason = failureReason;
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetOperationMessageGuidAsync(int operationId, string messageGuid)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
|
||||
Reference in New Issue
Block a user