wiring up new auth endpoint
This commit is contained in:
parent
b6999cef0a
commit
a13fb49942
17 changed files with 850 additions and 37 deletions
|
@ -1,9 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
using MediatR;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
|
||||
namespace Sledgemapper.Api.Commands
|
||||
{
|
||||
public class GetCampaignsCommand : IRequest<List<Core.Entities.Campaign>>
|
||||
public class GetCampaignsCommand : IRequest<List<Campaign>>
|
||||
{
|
||||
public string UserId { get; private set; }
|
||||
public GetCampaignsCommand(string userId)
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Sledgemapper.Api.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<List<Core.Entities.Campaign>> Get()
|
||||
public async Task<List<Campaign>> Get()
|
||||
{
|
||||
var result = await _mediator.Send(new GetCampaignsCommand(UserId));
|
||||
return result;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Sledgemapper.Entities;
|
||||
|
@ -7,7 +8,7 @@ namespace Sledgemapper.Api.Core.Entities
|
|||
[Index(nameof(CampaignName), nameof(OwnerId), IsUnique = true)]
|
||||
public class Campaign
|
||||
{
|
||||
public int CampaignId { get; set; }
|
||||
public Guid CampaignId { get; set; }
|
||||
public string CampaignName { get; set; }
|
||||
|
||||
public string OwnerId { get; set; }
|
||||
|
|
|
@ -2,6 +2,7 @@ using MediatR;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Sledgemapper.Api.Commands;
|
||||
using Sledgemapper.Api.Infrastructure.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -10,7 +11,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class GetCampaignsCommandHandler : IRequestHandler<GetCampaignsCommand, List<Core.Entities.Campaign>>
|
||||
public class GetCampaignsCommandHandler : IRequestHandler<GetCampaignsCommand, List<Campaign>>
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly SledgemapperDbContext _dbcontext;
|
||||
|
@ -21,20 +22,22 @@ namespace Sledgemapper.Api.Handlers
|
|||
_dbcontext = dbcontext;
|
||||
}
|
||||
|
||||
public async Task<List<Core.Entities.Campaign>> Handle(GetCampaignsCommand command, CancellationToken cancellationToken)
|
||||
public async Task<List<Campaign>> Handle(GetCampaignsCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
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.Owner).Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user));
|
||||
|
||||
return campaigns.ToList();
|
||||
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()})
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return new List<Core.Entities.Campaign>();
|
||||
return new List<Campaign>();
|
||||
}
|
||||
}
|
||||
}
|
503
Sledgemapper.Api/Migrations/20210528182730_ChangeCompanyId.Designer.cs
generated
Normal file
503
Sledgemapper.Api/Migrations/20210528182730_ChangeCompanyId.Designer.cs
generated
Normal file
|
@ -0,0 +1,503 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Sledgemapper.Api.Infrastructure.Data;
|
||||
|
||||
namespace Sledgemapper.Api.Migrations
|
||||
{
|
||||
[DbContext(typeof(SledgemapperDbContext))]
|
||||
[Migration("20210528182730_ChangeCompanyId")]
|
||||
partial class ChangeCompanyId
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "5.0.6");
|
||||
|
||||
modelBuilder.Entity("CampaignUser", b =>
|
||||
{
|
||||
b.Property<Guid>("CampaignsCampaignId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("InvitedUsersId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("CampaignsCampaignId", "InvitedUsersId");
|
||||
|
||||
b.HasIndex("InvitedUsersId");
|
||||
|
||||
b.ToTable("CampaignUser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Core.Entities.Campaign", b =>
|
||||
{
|
||||
b.Property<Guid>("CampaignId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CampaignName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("OwnerId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("CampaignId");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.HasIndex("CampaignName", "OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Campaigns");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Core.Entities.Map", b =>
|
||||
{
|
||||
b.Property<int>("MapId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CampaignId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid?>("CampaignId1")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("MapName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("MapId");
|
||||
|
||||
b.HasIndex("CampaignId1");
|
||||
|
||||
b.ToTable("Maps");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Models.MapLog", b =>
|
||||
{
|
||||
b.Property<int>("MapLogId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Object")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Operation")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SessionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("Timestamp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("MapLogId");
|
||||
|
||||
b.ToTable("MapLogs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Models.Session", b =>
|
||||
{
|
||||
b.Property<int>("SessionId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("OwnerUserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("SessionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("SessionId");
|
||||
|
||||
b.ToTable("Sessions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Models.SessionUser", b =>
|
||||
{
|
||||
b.Property<int>("SessionUserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("SessionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("SessionUserId");
|
||||
|
||||
b.ToTable("SessionUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Models.Snapshot", b =>
|
||||
{
|
||||
b.Property<int>("SnapshotId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Object")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SessionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("Timestamp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.HasKey("SnapshotId");
|
||||
|
||||
b.ToTable("Snapshots");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Models.UserConnection", b =>
|
||||
{
|
||||
b.Property<int>("UserConnectionId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ConnectionId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("UserConnectionId");
|
||||
|
||||
b.ToTable("UserConnections");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Entities.User", b =>
|
||||
{
|
||||
b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Initials")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<byte[]>("PasswordSalt")
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CampaignUser", b =>
|
||||
{
|
||||
b.HasOne("Sledgemapper.Api.Core.Entities.Campaign", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CampaignsCampaignId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Sledgemapper.Entities.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("InvitedUsersId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Core.Entities.Campaign", b =>
|
||||
{
|
||||
b.HasOne("Sledgemapper.Entities.User", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId");
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Core.Entities.Map", b =>
|
||||
{
|
||||
b.HasOne("Sledgemapper.Api.Core.Entities.Campaign", null)
|
||||
.WithMany("Maps")
|
||||
.HasForeignKey("CampaignId1");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Entities.User", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithOne()
|
||||
.HasForeignKey("Sledgemapper.Entities.User", "Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Core.Entities.Campaign", b =>
|
||||
{
|
||||
b.Navigation("Maps");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
110
Sledgemapper.Api/Migrations/20210528182730_ChangeCompanyId.cs
Normal file
110
Sledgemapper.Api/Migrations/20210528182730_ChangeCompanyId.cs
Normal file
|
@ -0,0 +1,110 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Sledgemapper.Api.Migrations
|
||||
{
|
||||
public partial class ChangeCompanyId : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Maps_Campaigns_CampaignId",
|
||||
table: "Maps");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Maps_CampaignId",
|
||||
table: "Maps");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Username",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "CampaignId1",
|
||||
table: "Maps",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "CampaignsCampaignId",
|
||||
table: "CampaignUser",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "CampaignId",
|
||||
table: "Campaigns",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER")
|
||||
.OldAnnotation("Sqlite:Autoincrement", true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Maps_CampaignId1",
|
||||
table: "Maps",
|
||||
column: "CampaignId1");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Maps_Campaigns_CampaignId1",
|
||||
table: "Maps",
|
||||
column: "CampaignId1",
|
||||
principalTable: "Campaigns",
|
||||
principalColumn: "CampaignId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Maps_Campaigns_CampaignId1",
|
||||
table: "Maps");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Maps_CampaignId1",
|
||||
table: "Maps");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CampaignId1",
|
||||
table: "Maps");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Username",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "CampaignsCampaignId",
|
||||
table: "CampaignUser",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "CampaignId",
|
||||
table: "Campaigns",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT")
|
||||
.Annotation("Sqlite:Autoincrement", true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Maps_CampaignId",
|
||||
table: "Maps",
|
||||
column: "CampaignId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Maps_Campaigns_CampaignId",
|
||||
table: "Maps",
|
||||
column: "CampaignId",
|
||||
principalTable: "Campaigns",
|
||||
principalColumn: "CampaignId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,12 +14,12 @@ namespace Sledgemapper.Api.Migrations
|
|||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "5.0.3");
|
||||
.HasAnnotation("ProductVersion", "5.0.6");
|
||||
|
||||
modelBuilder.Entity("CampaignUser", b =>
|
||||
{
|
||||
b.Property<int>("CampaignsCampaignId")
|
||||
.HasColumnType("INTEGER");
|
||||
b.Property<Guid>("CampaignsCampaignId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("InvitedUsersId")
|
||||
.HasColumnType("TEXT");
|
||||
|
@ -229,9 +229,9 @@ namespace Sledgemapper.Api.Migrations
|
|||
|
||||
modelBuilder.Entity("Sledgemapper.Api.Core.Entities.Campaign", b =>
|
||||
{
|
||||
b.Property<int>("CampaignId")
|
||||
b.Property<Guid>("CampaignId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CampaignName")
|
||||
.HasColumnType("TEXT");
|
||||
|
@ -258,13 +258,16 @@ namespace Sledgemapper.Api.Migrations
|
|||
b.Property<int>("CampaignId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid?>("CampaignId1")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("MapName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("MapId");
|
||||
|
||||
b.HasIndex("CampaignId");
|
||||
b.HasIndex("CampaignId1");
|
||||
|
||||
b.ToTable("Maps");
|
||||
});
|
||||
|
@ -394,9 +397,6 @@ namespace Sledgemapper.Api.Migrations
|
|||
b.Property<byte[]>("PasswordSalt")
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
|
@ -479,9 +479,7 @@ namespace Sledgemapper.Api.Migrations
|
|||
{
|
||||
b.HasOne("Sledgemapper.Api.Core.Entities.Campaign", null)
|
||||
.WithMany("Maps")
|
||||
.HasForeignKey("CampaignId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("CampaignId1");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Sledgemapper.Entities.User", b =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue