Implement file upload
This commit is contained in:
@ -10,5 +10,21 @@ namespace Hcs.WebApp.Services
|
||||
using var context = GetNewContext();
|
||||
return await context.FilesToParse.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<FileToParse> AddFileToParseAsync(string path, string fileName, string uploaderId, DateTime uploadedAt)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
var fileToParse = new FileToParse()
|
||||
{
|
||||
Path = path,
|
||||
FileName = fileName,
|
||||
UploaderId = uploaderId,
|
||||
UploadedAt = uploadedAt
|
||||
};
|
||||
|
||||
await context.FilesToParse.AddAsync(fileToParse);
|
||||
await context.SaveChangesAsync();
|
||||
return fileToParse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using Hcs.WebApp.Data.Hcs.CampaignArgs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hcs.WebApp.Services
|
||||
@ -69,7 +70,7 @@ namespace Hcs.WebApp.Services
|
||||
select operation).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Campaign> InitiateCampaignAsync(Campaign.CampaignType type, string initiatorId)
|
||||
public async Task<Campaign> InitiateCampaignAsync(Campaign.CampaignType type, string initiatorId, ICampaignArgs? args = null)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
var campaign = new Campaign()
|
||||
@ -78,6 +79,12 @@ namespace Hcs.WebApp.Services
|
||||
InitiatorId = initiatorId,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
if (args != null)
|
||||
{
|
||||
campaign.SerializeArgs(args);
|
||||
}
|
||||
|
||||
await context.Campaigns.AddAsync(campaign);
|
||||
await context.SaveChangesAsync();
|
||||
return campaign;
|
||||
|
||||
Reference in New Issue
Block a user