Changed api methods
This commit is contained in:
parent
a27049568b
commit
c893f2ffd9
Binary file not shown.
Binary file not shown.
@ -23,13 +23,13 @@ namespace StudyLib.API.Controllers
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{groupId}")]
|
[HttpGet("list/{groupId}")]
|
||||||
public async Task<ActionResult<IEnumerable<GroupCandidate>>> GetGroupCandidates(long groupId)
|
public async Task<ActionResult<IEnumerable<GroupCandidate>>> GetGroupCandidates(long groupId)
|
||||||
{
|
{
|
||||||
return await _context.GroupCandidates.Where(g => g.Group.ID == groupId).ToListAsync();
|
return await _context.GroupCandidates.Where(g => g.Group.ID == groupId).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost("join-request")]
|
||||||
public async Task<ActionResult<GroupCandidate>> GroupCandidate(GroupCandidate groupCandidate)
|
public async Task<ActionResult<GroupCandidate>> GroupCandidate(GroupCandidate groupCandidate)
|
||||||
{
|
{
|
||||||
_context.GroupCandidates.Add(groupCandidate);
|
_context.GroupCandidates.Add(groupCandidate);
|
||||||
@ -38,7 +38,7 @@ namespace StudyLib.API.Controllers
|
|||||||
return CreatedAtAction("GetGroupCandidate", groupCandidate);
|
return CreatedAtAction("GetGroupCandidate", groupCandidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{groupId}/{userId}")]
|
[HttpDelete("delete/{groupId}/{userId}")]
|
||||||
public async Task<IActionResult> DeleteGroupCandidate(long groupId, string userId)
|
public async Task<IActionResult> DeleteGroupCandidate(long groupId, string userId)
|
||||||
{
|
{
|
||||||
var groupCandidate = await _context.GroupCandidates.Where(g => g.Group.ID == groupId && g.User.Id == userId).FirstAsync();
|
var groupCandidate = await _context.GroupCandidates.Where(g => g.Group.ID == groupId && g.User.Id == userId).FirstAsync();
|
||||||
|
@ -20,13 +20,26 @@ namespace StudyLib.API.Controllers
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet("list")]
|
||||||
public async Task<ActionResult<IEnumerable<Group>>> GetGroups()
|
public async Task<ActionResult<IEnumerable<Group>>> GetGroups()
|
||||||
{
|
{
|
||||||
return await _context.Groups.Include(g => g.Users).Include(g => g.Subjects).ToListAsync();
|
return await _context.Groups.Include(g => g.Users).Include(g => g.Subjects).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("current-user-groups/{userId}")]
|
||||||
|
public async Task<ActionResult<IEnumerable<Group>>> GetCurrentUserGroups(string userId)
|
||||||
|
{
|
||||||
|
var user = await _context.Users.FindAsync(userId);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(user.Groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("get-by-id/{id}")]
|
||||||
public async Task<ActionResult<Group>> GetGroup(long id)
|
public async Task<ActionResult<Group>> GetGroup(long id)
|
||||||
{
|
{
|
||||||
var group = await _context.Groups.Where(g => g.ID == id).Include(g => g.Users).Include(g => g.Subjects).SingleOrDefaultAsync();
|
var group = await _context.Groups.Where(g => g.ID == id).Include(g => g.Users).Include(g => g.Subjects).SingleOrDefaultAsync();
|
||||||
@ -39,7 +52,7 @@ namespace StudyLib.API.Controllers
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{id}")]
|
[HttpPut("update/{id}")]
|
||||||
public async Task<IActionResult> PutGroup(long id, Group group)
|
public async Task<IActionResult> PutGroup(long id, Group group)
|
||||||
{
|
{
|
||||||
if (id != group.ID)
|
if (id != group.ID)
|
||||||
@ -68,7 +81,37 @@ namespace StudyLib.API.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpGet("leave/{id}/{userId}")]
|
||||||
|
public async Task<IActionResult> LeaveGroup(long id, string userId)
|
||||||
|
{
|
||||||
|
var user = await _context.Users.FindAsync(userId);
|
||||||
|
|
||||||
|
var groups = user.Groups.Where(g => g.ID != id).ToList();
|
||||||
|
|
||||||
|
user.Groups = groups;
|
||||||
|
|
||||||
|
_context.Entry(user).State = EntityState.Modified;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch (DbUpdateConcurrencyException)
|
||||||
|
{
|
||||||
|
if (!GroupExists(id))
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("add")]
|
||||||
public async Task<ActionResult<Group>> PostGroup(Group group)
|
public async Task<ActionResult<Group>> PostGroup(Group group)
|
||||||
{
|
{
|
||||||
_context.Groups.Add(group);
|
_context.Groups.Add(group);
|
||||||
@ -78,7 +121,7 @@ namespace StudyLib.API.Controllers
|
|||||||
return CreatedAtAction("GetGroup", new { id = group.ID }, group);
|
return CreatedAtAction("GetGroup", new { id = group.ID }, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("delete/{id}")]
|
||||||
public async Task<ActionResult<Group>> DeleteGroup(long id)
|
public async Task<ActionResult<Group>> DeleteGroup(long id)
|
||||||
{
|
{
|
||||||
var group = await _context.Groups.FindAsync(id);
|
var group = await _context.Groups.FindAsync(id);
|
||||||
|
@ -21,13 +21,13 @@ namespace StudyLib.API.Controllers
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("list")]
|
[HttpGet("list-by-group-id/{groupId}")]
|
||||||
public async Task<ActionResult<IEnumerable<SubjectDeleteRequest>>> GetSubjectDeleteRequest()
|
public async Task<ActionResult<IEnumerable<SubjectDeleteRequest>>> GetSubjectDeleteRequest(long groupId)
|
||||||
{
|
{
|
||||||
return await _context.SubjectDeleteRequests.Include(s => s.Subject).ToListAsync();
|
return await _context.SubjectDeleteRequests.Where(s => s.Subject.GroupId == groupId).Include(s => s.Subject).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("approveDeletion")]
|
[HttpPost("approve")]
|
||||||
public async Task<ActionResult<SubjectDeleteRequest>> ApproveSubjectDeleteRequest(SubjectDeleteRequest deletionRequest)
|
public async Task<ActionResult<SubjectDeleteRequest>> ApproveSubjectDeleteRequest(SubjectDeleteRequest deletionRequest)
|
||||||
{
|
{
|
||||||
var subjectDeleteRequest = await _context.SubjectDeleteRequests.Where(s => s.ID == deletionRequest.ID).Include(s => s.Subject).SingleOrDefaultAsync();
|
var subjectDeleteRequest = await _context.SubjectDeleteRequests.Where(s => s.ID == deletionRequest.ID).Include(s => s.Subject).SingleOrDefaultAsync();
|
||||||
@ -43,7 +43,7 @@ namespace StudyLib.API.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("addDeletionRequest")]
|
[HttpPost("add")]
|
||||||
public async Task<ActionResult<SubjectDeleteRequest>> AddSubjectDeleteRequest(SubjectDeleteRequest deletionRequest)
|
public async Task<ActionResult<SubjectDeleteRequest>> AddSubjectDeleteRequest(SubjectDeleteRequest deletionRequest)
|
||||||
{
|
{
|
||||||
_context.SubjectDeleteRequests.Add(deletionRequest);
|
_context.SubjectDeleteRequests.Add(deletionRequest);
|
||||||
@ -52,7 +52,7 @@ namespace StudyLib.API.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("cancelDeletion/{id}")]
|
[HttpDelete("cancel/{id}")]
|
||||||
public async Task<IActionResult> CancelSubjectDeleteRequest(long id)
|
public async Task<IActionResult> CancelSubjectDeleteRequest(long id)
|
||||||
{
|
{
|
||||||
var subjectDeleteRequest = await _context.SubjectDeleteRequests.FindAsync(id);
|
var subjectDeleteRequest = await _context.SubjectDeleteRequests.FindAsync(id);
|
||||||
|
@ -24,15 +24,13 @@ namespace StudyLib.API.Controllers
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/Subjects
|
[HttpGet("list-by-group-id/{groupId}")]
|
||||||
[HttpGet]
|
public async Task<ActionResult<IEnumerable<Subject>>> GetSubjects(long groupId)
|
||||||
public async Task<ActionResult<IEnumerable<Subject>>> GetSubjects()
|
|
||||||
{
|
{
|
||||||
return await _context.Subjects.Include(s => s.Comments).Include(s => s.Assignments).Include(s => s.Tests).ToListAsync();
|
return await _context.Subjects.Where(s => s.Group.ID == groupId).Include(s => s.Comments).Include(s => s.Assignments).Include(s => s.Tests).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/Subjects/5
|
[HttpGet("get-by-id/{id}")]
|
||||||
[HttpGet("{id}")]
|
|
||||||
public async Task<ActionResult<Subject>> GetSubject(long id)
|
public async Task<ActionResult<Subject>> GetSubject(long id)
|
||||||
{
|
{
|
||||||
var subject = await _context.Subjects.Where(s => s.ID == id).Include(s => s.Comments).Include(s => s.Assignments).Include(s => s.Tests).SingleOrDefaultAsync();
|
var subject = await _context.Subjects.Where(s => s.ID == id).Include(s => s.Comments).Include(s => s.Assignments).Include(s => s.Tests).SingleOrDefaultAsync();
|
||||||
@ -45,10 +43,7 @@ namespace StudyLib.API.Controllers
|
|||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PUT: api/Subjects/5
|
[HttpPut("update/{id}")]
|
||||||
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
|
||||||
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
|
||||||
[HttpPut("{id}")]
|
|
||||||
public async Task<IActionResult> PutSubject(long id, Subject subject)
|
public async Task<IActionResult> PutSubject(long id, Subject subject)
|
||||||
{
|
{
|
||||||
if (id != subject.ID)
|
if (id != subject.ID)
|
||||||
@ -112,10 +107,7 @@ namespace StudyLib.API.Controllers
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: api/Subjects
|
[HttpPost("add")]
|
||||||
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
|
||||||
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<ActionResult<Subject>> PostSubject(Subject subject)
|
public async Task<ActionResult<Subject>> PostSubject(Subject subject)
|
||||||
{
|
{
|
||||||
_context.Subjects.Add(subject);
|
_context.Subjects.Add(subject);
|
||||||
@ -126,7 +118,7 @@ namespace StudyLib.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DELETE: api/Subjects/5
|
// DELETE: api/Subjects/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("delete/{id}")]
|
||||||
public async Task<ActionResult<Subject>> DeleteSubject(long id)
|
public async Task<ActionResult<Subject>> DeleteSubject(long id)
|
||||||
{
|
{
|
||||||
var subject = await _context.Subjects.FindAsync(id);
|
var subject = await _context.Subjects.FindAsync(id);
|
||||||
|
@ -11,7 +11,7 @@ namespace StudyLib.API.Data
|
|||||||
public static void Initialize(StudyLibContext context)
|
public static void Initialize(StudyLibContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (context.Subjects.Any())
|
/* if (context.Subjects.Any())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ namespace StudyLib.API.Data
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ namespace StudyLib.Models
|
|||||||
|
|
||||||
public bool MainExam { get; set; }
|
public bool MainExam { get; set; }
|
||||||
|
|
||||||
|
public long GroupId { get; set; }
|
||||||
|
|
||||||
|
public Group Group { get; set; }
|
||||||
|
|
||||||
public DateTime ExamDate { get; set; }
|
public DateTime ExamDate { get; set; }
|
||||||
|
|
||||||
public ICollection<Test> Tests { get; set; }
|
public ICollection<Test> Tests { get; set; }
|
||||||
|
570
Migrations/20201223201708_AddedGroupToSubject.Designer.cs
generated
Normal file
570
Migrations/20201223201708_AddedGroupToSubject.Designer.cs
generated
Normal file
@ -0,0 +1,570 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using StudyLib.API.Data;
|
||||||
|
|
||||||
|
namespace StudyLib.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(StudyLibContext))]
|
||||||
|
[Migration("20201223201708_AddedGroupToSubject")]
|
||||||
|
partial class AddedGroupToSubject
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.UseIdentityColumns()
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||||
|
.HasAnnotation("ProductVersion", "5.0.0");
|
||||||
|
|
||||||
|
modelBuilder.Entity("GroupUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("GroupsID")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("UsersId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.HasKey("GroupsID", "UsersId");
|
||||||
|
|
||||||
|
b.HasIndex("UsersId");
|
||||||
|
|
||||||
|
b.ToTable("GroupUser");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("nvarchar(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("nvarchar(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex")
|
||||||
|
.HasFilter("[NormalizedName] IS NOT NULL");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasMaxLength(128)
|
||||||
|
.HasColumnType("nvarchar(128)");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasMaxLength(128)
|
||||||
|
.HasColumnType("nvarchar(128)");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasMaxLength(128)
|
||||||
|
.HasColumnType("nvarchar(128)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(128)
|
||||||
|
.HasColumnType("nvarchar(128)");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.Comment", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<long>("SubjectId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Text")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.ToTable("Comments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.Group", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("AdminId")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Year")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Groups");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.GroupCandidate", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<long>("GroupId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("GroupId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("GroupCandidates");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.SubjectDeleteRequest", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<long>("SubjectId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.ToTable("SubjectDeleteRequests");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("nvarchar(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("FullName")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("datetimeoffset");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("nvarchar(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("nvarchar(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("nvarchar(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex")
|
||||||
|
.HasFilter("[NormalizedUserName] IS NOT NULL");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.Models.Assignment", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<DateTime>("Deadline")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("FinalMarkPercent")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long>("SubjectId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.ToTable("Assignments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.Models.Subject", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExamDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<long>("GroupId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("LabTeacher")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("LectureTeacher")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("MainExam")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("GroupId");
|
||||||
|
|
||||||
|
b.ToTable("Subjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.Models.Test", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<double>("FinalMarkPercent")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("Scope")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<long>("SubjectId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.ToTable("Tests");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("GroupUser", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.API.Models.Group", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("GroupsID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("StudyLib.API.Models.User", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UsersId")
|
||||||
|
.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("StudyLib.API.Models.User", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.API.Models.User", 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("StudyLib.API.Models.User", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.API.Models.User", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.Comment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.Models.Subject", "Subject")
|
||||||
|
.WithMany("Comments")
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.GroupCandidate", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.API.Models.Group", "Group")
|
||||||
|
.WithMany("GroupCandidates")
|
||||||
|
.HasForeignKey("GroupId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("StudyLib.API.Models.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("Group");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.SubjectDeleteRequest", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.Models.Subject", "Subject")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.Models.Assignment", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.Models.Subject", "Subject")
|
||||||
|
.WithMany("Assignments")
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.Models.Subject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.API.Models.Group", "Group")
|
||||||
|
.WithMany("Subjects")
|
||||||
|
.HasForeignKey("GroupId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Group");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.Models.Test", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("StudyLib.Models.Subject", "Subject")
|
||||||
|
.WithMany("Tests")
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.API.Models.Group", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("GroupCandidates");
|
||||||
|
|
||||||
|
b.Navigation("Subjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("StudyLib.Models.Subject", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Assignments");
|
||||||
|
|
||||||
|
b.Navigation("Comments");
|
||||||
|
|
||||||
|
b.Navigation("Tests");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
Migrations/20201223201708_AddedGroupToSubject.cs
Normal file
75
Migrations/20201223201708_AddedGroupToSubject.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace StudyLib.Migrations
|
||||||
|
{
|
||||||
|
public partial class AddedGroupToSubject : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Subjects_Groups_GroupID",
|
||||||
|
table: "Subjects");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GroupID",
|
||||||
|
table: "Subjects",
|
||||||
|
newName: "GroupId");
|
||||||
|
|
||||||
|
migrationBuilder.RenameIndex(
|
||||||
|
name: "IX_Subjects_GroupID",
|
||||||
|
table: "Subjects",
|
||||||
|
newName: "IX_Subjects_GroupId");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<long>(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "Subjects",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0L,
|
||||||
|
oldClrType: typeof(long),
|
||||||
|
oldType: "bigint",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Subjects_Groups_GroupId",
|
||||||
|
table: "Subjects",
|
||||||
|
column: "GroupId",
|
||||||
|
principalTable: "Groups",
|
||||||
|
principalColumn: "ID",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Subjects_Groups_GroupId",
|
||||||
|
table: "Subjects");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "GroupId",
|
||||||
|
table: "Subjects",
|
||||||
|
newName: "GroupID");
|
||||||
|
|
||||||
|
migrationBuilder.RenameIndex(
|
||||||
|
name: "IX_Subjects_GroupId",
|
||||||
|
table: "Subjects",
|
||||||
|
newName: "IX_Subjects_GroupID");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<long>(
|
||||||
|
name: "GroupID",
|
||||||
|
table: "Subjects",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(long),
|
||||||
|
oldType: "bigint");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Subjects_Groups_GroupID",
|
||||||
|
table: "Subjects",
|
||||||
|
column: "GroupID",
|
||||||
|
principalTable: "Groups",
|
||||||
|
principalColumn: "ID",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -359,7 +359,7 @@ namespace StudyLib.Migrations
|
|||||||
b.Property<DateTime>("ExamDate")
|
b.Property<DateTime>("ExamDate")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<long?>("GroupID")
|
b.Property<long>("GroupId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
b.Property<string>("LabTeacher")
|
b.Property<string>("LabTeacher")
|
||||||
@ -377,7 +377,7 @@ namespace StudyLib.Migrations
|
|||||||
|
|
||||||
b.HasKey("ID");
|
b.HasKey("ID");
|
||||||
|
|
||||||
b.HasIndex("GroupID");
|
b.HasIndex("GroupId");
|
||||||
|
|
||||||
b.ToTable("Subjects");
|
b.ToTable("Subjects");
|
||||||
});
|
});
|
||||||
@ -527,9 +527,13 @@ namespace StudyLib.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("StudyLib.Models.Subject", b =>
|
modelBuilder.Entity("StudyLib.Models.Subject", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("StudyLib.API.Models.Group", null)
|
b.HasOne("StudyLib.API.Models.Group", "Group")
|
||||||
.WithMany("Subjects")
|
.WithMany("Subjects")
|
||||||
.HasForeignKey("GroupID");
|
.HasForeignKey("GroupId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Group");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("StudyLib.Models.Test", b =>
|
modelBuilder.Entity("StudyLib.Models.Test", b =>
|
||||||
|
@ -14,7 +14,7 @@ namespace StudyLib
|
|||||||
{
|
{
|
||||||
var services = scope.ServiceProvider;
|
var services = scope.ServiceProvider;
|
||||||
var context = services.GetService<StudyLibContext>();
|
var context = services.GetService<StudyLibContext>();
|
||||||
StudyLibDataSeeder.Initialize(context);
|
//StudyLibDataSeeder.Initialize(context);
|
||||||
}
|
}
|
||||||
host.Run();
|
host.Run();
|
||||||
// CreateHostBuilder(args).Build().Run();
|
// CreateHostBuilder(args).Build().Run();
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
|||||||
73a2189dbe3e51a4bc9dfe1696e53c26fb2ec4ea
|
60b4309f39d35789ac308a57134eb3df9d09f22e
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user