tentative campaign map management
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c46e66595b
commit
4c345bd044
37 changed files with 1693 additions and 50 deletions
|
@ -28,10 +28,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
{
|
||||
var user = await _dbcontext.Users.FindAsync(command.UserId);
|
||||
_dbcontext.Attach(user);
|
||||
var campaigns = _dbcontext.Campaigns.Include(c => c.InvitedUsers).Include(c => c.Owner).Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user));
|
||||
var campaigns = _dbcontext.Campaigns.Include(c => c.InvitedUsers).Include(c => c.Maps).Include(c => c.Owner).Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user));
|
||||
|
||||
return campaigns.
|
||||
Select(c => new Shared.Entities.Campaign { Id = c.CampaignId, Name = c.CampaignName, Maps = c.Maps.Select(m => new Shared.Entities.Map { SessionName = m.MapName }).ToList()})
|
||||
Select(c => new Shared.Entities.Campaign { Id = c.CampaignId, Name = c.CampaignName, Maps = c.Maps.Select(m => new Shared.Entities.Map { SessionName = m.MapName }).ToList() })
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -2,6 +2,7 @@ using MediatR;
|
|||
using Sledgemapper.Api.Commands;
|
||||
using Sledgemapper.Api.Infrastructure.Data;
|
||||
using Sledgemapper.Api.Models;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -20,10 +21,14 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewSessionCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var campaign = _dbcontext.Campaigns.First(c => c.CampaignName == notification.Campaign && c.OwnerId == notification.UserId.ToString());
|
||||
|
||||
_dbcontext.Sessions.Add(new Session
|
||||
{
|
||||
SessionName = notification.SessionName,
|
||||
OwnerUserId = notification.UserId
|
||||
OwnerUserId = notification.UserId,
|
||||
CampaignId = campaign.CampaignId
|
||||
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue