Documents - нужно сделать update и пофиксить delete.
многие ко многим работает (нужен фикс update и delete)
This commit is contained in:
parent
c87f2caaac
commit
7e3706b2f6
@ -69,6 +69,11 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public int GetNumberOfPages(int userId, int pageSize = 10)
|
||||
{
|
||||
return _documentStorage.GetNumberOfPages(userId, pageSize);
|
||||
}
|
||||
|
||||
private void CheckModel(DocumentBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -61,7 +61,7 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
})
|
||||
.Any(document => document.StudentDocument.ContainsKey(student.Value.Id)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
|
||||
.Any(document => document.DocumentStudents.Contains(student.Value)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
|
||||
.Join(_documentStorage.GetFullList(),
|
||||
t1 => t1.Value.Id,
|
||||
t2 => t2.UserId,
|
||||
|
@ -77,7 +77,7 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
})
|
||||
.Any(document => document.StudentDocument.ContainsKey(student.Value.Id)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
|
||||
.Any(document => document.DocumentStudents.Any(x => x.Id == student.Value.Id)))//Выбираем студентов, которые есть в приказах за выбранный промежуток времени
|
||||
.Select(student => (
|
||||
StudentFIO: $"{student.Value.Name} {student.Value.Surname}",
|
||||
EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = student.Value.EducationStatusId })?.Name ?? "не удалось получить"))
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityModels.Models;
|
||||
|
||||
namespace UniversityContracts.BindingModels
|
||||
@ -13,6 +14,6 @@ namespace UniversityContracts.BindingModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public int UserId { get; set; }
|
||||
public Dictionary<int, IStudentModel> StudentDocument { get; set; } = new();
|
||||
public List<StudentViewModel> DocumentStudents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityContracts.BusinessLogicContracts
|
||||
@ -16,5 +17,6 @@ namespace UniversityContracts.BusinessLogicContracts
|
||||
bool Delete(DocumentBindingModel model);
|
||||
List<DocumentViewModel>? ReadList(DocumentSearchModel? model);
|
||||
DocumentViewModel? ReadElement(DocumentSearchModel model);
|
||||
int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ namespace UniversityContracts.BusinessLogicContracts
|
||||
bool Delete(EducationStatusBindingModel model);
|
||||
List<EducationStatusViewModel>? ReadList(EducationStatusSearchModel? model);
|
||||
EducationStatusViewModel? ReadElement(EducationStatusSearchModel model);
|
||||
public int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ namespace UniversityContracts.BusinessLogicContracts
|
||||
bool Delete(StudentBindingModel model);
|
||||
List<StudentViewModel>? ReadList(StudentSearchModel? model);
|
||||
StudentViewModel? ReadElement(StudentSearchModel model);
|
||||
public int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,7 @@ namespace UniversityContracts.SearchModels
|
||||
public int? UserId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? PageNumber { get; set; }
|
||||
public int? PageSize { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace UniversityContracts.StoragesContracts
|
||||
DocumentViewModel? Insert(DocumentBindingModel model);
|
||||
DocumentViewModel? Update(DocumentBindingModel model);
|
||||
DocumentViewModel? Delete(DocumentBindingModel model);
|
||||
int GetNumberOfPages(int userId, int pageSize);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ namespace UniversityContracts.StoragesContracts
|
||||
EducationStatusViewModel? Insert(EducationStatusBindingModel model);
|
||||
EducationStatusViewModel? Update(EducationStatusBindingModel model);
|
||||
EducationStatusViewModel? Delete(EducationStatusBindingModel model);
|
||||
public int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ namespace UniversityContracts.StoragesContracts
|
||||
StudentViewModel? Insert(StudentBindingModel model);
|
||||
StudentViewModel? Update(StudentBindingModel model);
|
||||
StudentViewModel? Delete(StudentBindingModel model);
|
||||
public int GetNumberOfPages(int userId, int pageSize);
|
||||
int GetNumberOfPages(int userId, int pageSize);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ namespace UniversityContracts.ViewModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Дата создания документа")]
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, IStudentModel> StudentDocument { get; set; } = new();
|
||||
public List<StudentViewModel> DocumentStudents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -22,5 +23,18 @@ namespace UniversityContracts.ViewModels
|
||||
public string EducationStatusName { get; set; } = string.Empty;
|
||||
public int StudentCard { get; set; }
|
||||
public int? EducationStatusId { get; set; }
|
||||
|
||||
public StudentViewModel() { }
|
||||
|
||||
public StudentViewModel(IStudentModel model)
|
||||
{
|
||||
Id = model.Id;
|
||||
UserId = model.UserId;
|
||||
Name = model.Name;
|
||||
Surname = model.Surname;
|
||||
DateOfBirth = model.DateOfBirth;
|
||||
StudentCard = model.StudentCard;
|
||||
EducationStatusId = model.EducationStatusId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,34 @@ namespace UniversityDataBaseImplemet
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<User> User { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<StudentDocument>()
|
||||
.HasKey(x => new { x.StudentId, x.DocumentId });
|
||||
modelBuilder.Entity<EducationGroupDocument>()
|
||||
.HasKey(x => new { x.EducationGroupId, x.DocumentId });
|
||||
modelBuilder.Entity<EducationGroupStream>()
|
||||
.HasKey(x => new { x.EducationGroupId, x.StreamId });
|
||||
modelBuilder.Entity<StudentStream>()
|
||||
.HasKey(x => new { x.StudentId, x.StreamId });
|
||||
|
||||
modelBuilder.Entity<Document>()
|
||||
.HasOne(b => b.User)
|
||||
.WithMany(a => a.Documents)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
modelBuilder.Entity<EducationStatus>()
|
||||
.HasOne(b => b.User)
|
||||
.WithMany(a => a.EducationStatuses)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
modelBuilder.Entity<Student>()
|
||||
.HasOne(b => b.User)
|
||||
.WithMany(a => a.Students)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
}
|
||||
|
||||
|
||||
public virtual DbSet<User> User { get; set; }
|
||||
public virtual DbSet<Document> Documents { get; set; }
|
||||
public virtual DbSet<Discipline> Discipline { get; set; }
|
||||
public virtual DbSet<EducationStatus> EducationStatuses { get; set; }
|
||||
|
@ -86,12 +86,13 @@ namespace UniversityDataBaseImplemet.Implements
|
||||
}
|
||||
public DocumentViewModel? Insert(DocumentBindingModel model)
|
||||
{
|
||||
var newDocument = Document.Create(model);
|
||||
|
||||
using var context = new Database();
|
||||
var newDocument = Document.Create(context, model);
|
||||
if(newDocument == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
context.Documents.Add(newDocument);
|
||||
context.SaveChanges();
|
||||
return newDocument.GetViewModel;
|
||||
@ -135,5 +136,13 @@ namespace UniversityDataBaseImplemet.Implements
|
||||
context.SaveChanges();
|
||||
return document.GetViewModel;
|
||||
}
|
||||
|
||||
public int GetNumberOfPages(int userId, int pageSize)
|
||||
{
|
||||
using var context = new Database();
|
||||
int carsCount = context.Students.Where(c => c.UserId == userId).Count();
|
||||
int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize);
|
||||
return numberOfpages != 0 ? numberOfpages : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
497
UniversityDataBaseImplemet/Migrations/20230518002601_nullableEdStatusId4.Designer.cs
generated
Normal file
497
UniversityDataBaseImplemet/Migrations/20230518002601_nullableEdStatusId4.Designer.cs
generated
Normal file
@ -0,0 +1,497 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using UniversityDataBaseImplemet;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20230518002601_nullableEdStatusId4")]
|
||||
partial class nullableEdStatusId4
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Discipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Hours")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("MarkType")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Discipline");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Documents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("NumberOfStudent")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("EducationGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupDocument", b =>
|
||||
{
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("EducationGroupId", "DocumentId");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.ToTable("EducationGroupsDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupStream", b =>
|
||||
{
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("EducationGroupId", "StreamId");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.ToTable("EducationGroupsStreams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("EducationStatuses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Course")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Streams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("EducationStatusId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StudentCard")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EducationStatusId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentDocument", b =>
|
||||
{
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StudentId", "DocumentId");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.ToTable("StudentDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StudentId", "StreamId");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.ToTable("StudentStreams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Discipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream")
|
||||
.WithMany()
|
||||
.HasForeignKey("StreamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Disciplines")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Stream");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Documents")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("EducationGroups")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupDocument", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Document", "Document")
|
||||
.WithMany("EducationGroupDocument")
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.EducationGroup", "EducationGroup")
|
||||
.WithMany("EducationGroupDocument")
|
||||
.HasForeignKey("EducationGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("EducationGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupStream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.EducationGroup", "EducationGroup")
|
||||
.WithMany("EducationGroupStream")
|
||||
.HasForeignKey("EducationGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream")
|
||||
.WithMany("EducationGroupStream")
|
||||
.HasForeignKey("StreamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("EducationGroup");
|
||||
|
||||
b.Navigation("Stream");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("EducationStatuses")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Streams")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.EducationStatus", "EducationStatus")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("EducationStatusId");
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("EducationStatus");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentDocument", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Document", "Document")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Student", "Student")
|
||||
.WithMany("DocumentStudents")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream")
|
||||
.WithMany("StreamStudents")
|
||||
.HasForeignKey("StreamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Student", "Student")
|
||||
.WithMany("StudentStream")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Stream");
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b =>
|
||||
{
|
||||
b.Navigation("EducationGroupDocument");
|
||||
|
||||
b.Navigation("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.Navigation("EducationGroupDocument");
|
||||
|
||||
b.Navigation("EducationGroupStream");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.Navigation("EducationGroupStream");
|
||||
|
||||
b.Navigation("StreamStudents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b =>
|
||||
{
|
||||
b.Navigation("DocumentStudents");
|
||||
|
||||
b.Navigation("StudentStream");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Disciplines");
|
||||
|
||||
b.Navigation("Documents");
|
||||
|
||||
b.Navigation("EducationGroups");
|
||||
|
||||
b.Navigation("EducationStatuses");
|
||||
|
||||
b.Navigation("Streams");
|
||||
|
||||
b.Navigation("Students");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,222 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class nullableEdStatusId4 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Documents_User_UserId",
|
||||
table: "Documents");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_StudentStreams",
|
||||
table: "StudentStreams");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_StudentStreams_StudentId",
|
||||
table: "StudentStreams");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_StudentDocuments",
|
||||
table: "StudentDocuments");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_StudentDocuments_StudentId",
|
||||
table: "StudentDocuments");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_EducationGroupsStreams",
|
||||
table: "EducationGroupsStreams");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EducationGroupsStreams_EducationGroupId",
|
||||
table: "EducationGroupsStreams");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_EducationGroupsDocuments",
|
||||
table: "EducationGroupsDocuments");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EducationGroupsDocuments_EducationGroupId",
|
||||
table: "EducationGroupsDocuments");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "StudentStreams",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "StudentDocuments",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "EducationGroupsStreams",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "EducationGroupsDocuments",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_StudentStreams",
|
||||
table: "StudentStreams",
|
||||
columns: new[] { "StudentId", "StreamId" });
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_StudentDocuments",
|
||||
table: "StudentDocuments",
|
||||
columns: new[] { "StudentId", "DocumentId" });
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_EducationGroupsStreams",
|
||||
table: "EducationGroupsStreams",
|
||||
columns: new[] { "EducationGroupId", "StreamId" });
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_EducationGroupsDocuments",
|
||||
table: "EducationGroupsDocuments",
|
||||
columns: new[] { "EducationGroupId", "DocumentId" });
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Documents_User_UserId",
|
||||
table: "Documents",
|
||||
column: "UserId",
|
||||
principalTable: "User",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Documents_User_UserId",
|
||||
table: "Documents");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_StudentStreams",
|
||||
table: "StudentStreams");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_StudentDocuments",
|
||||
table: "StudentDocuments");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_EducationGroupsStreams",
|
||||
table: "EducationGroupsStreams");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_EducationGroupsDocuments",
|
||||
table: "EducationGroupsDocuments");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "StudentStreams",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "StudentDocuments",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "EducationGroupsStreams",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Id",
|
||||
table: "EducationGroupsDocuments",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer")
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_StudentStreams",
|
||||
table: "StudentStreams",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_StudentDocuments",
|
||||
table: "StudentDocuments",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_EducationGroupsStreams",
|
||||
table: "EducationGroupsStreams",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_EducationGroupsDocuments",
|
||||
table: "EducationGroupsDocuments",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_StudentStreams_StudentId",
|
||||
table: "StudentStreams",
|
||||
column: "StudentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_StudentDocuments_StudentId",
|
||||
table: "StudentDocuments",
|
||||
column: "StudentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EducationGroupsStreams_EducationGroupId",
|
||||
table: "EducationGroupsStreams",
|
||||
column: "EducationGroupId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EducationGroupsDocuments_EducationGroupId",
|
||||
table: "EducationGroupsDocuments",
|
||||
column: "EducationGroupId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Documents_User_UserId",
|
||||
table: "Documents",
|
||||
column: "UserId",
|
||||
principalTable: "User",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
497
UniversityDataBaseImplemet/Migrations/20230518002727_nullableEdStatusId5.Designer.cs
generated
Normal file
497
UniversityDataBaseImplemet/Migrations/20230518002727_nullableEdStatusId5.Designer.cs
generated
Normal file
@ -0,0 +1,497 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using UniversityDataBaseImplemet;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20230518002727_nullableEdStatusId5")]
|
||||
partial class nullableEdStatusId5
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Discipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Hours")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("MarkType")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Discipline");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Documents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("NumberOfStudent")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("EducationGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupDocument", b =>
|
||||
{
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("EducationGroupId", "DocumentId");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.ToTable("EducationGroupsDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupStream", b =>
|
||||
{
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("EducationGroupId", "StreamId");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.ToTable("EducationGroupsStreams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("EducationStatuses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Course")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Streams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("EducationStatusId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StudentCard")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EducationStatusId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentDocument", b =>
|
||||
{
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StudentId", "DocumentId");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.ToTable("StudentDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StudentId", "StreamId");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.ToTable("StudentStreams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Discipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream")
|
||||
.WithMany()
|
||||
.HasForeignKey("StreamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Disciplines")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Stream");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Documents")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("EducationGroups")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupDocument", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Document", "Document")
|
||||
.WithMany("EducationGroupDocument")
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.EducationGroup", "EducationGroup")
|
||||
.WithMany("EducationGroupDocument")
|
||||
.HasForeignKey("EducationGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("EducationGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupStream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.EducationGroup", "EducationGroup")
|
||||
.WithMany("EducationGroupStream")
|
||||
.HasForeignKey("EducationGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream")
|
||||
.WithMany("EducationGroupStream")
|
||||
.HasForeignKey("StreamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("EducationGroup");
|
||||
|
||||
b.Navigation("Stream");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("EducationStatuses")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Streams")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.EducationStatus", "EducationStatus")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("EducationStatusId");
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("EducationStatus");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentDocument", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Document", "Document")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Student", "Student")
|
||||
.WithMany("DocumentStudents")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Stream", "Stream")
|
||||
.WithMany("StreamStudents")
|
||||
.HasForeignKey("StreamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.Student", "Student")
|
||||
.WithMany("StudentStream")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Stream");
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b =>
|
||||
{
|
||||
b.Navigation("EducationGroupDocument");
|
||||
|
||||
b.Navigation("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.Navigation("EducationGroupDocument");
|
||||
|
||||
b.Navigation("EducationGroupStream");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.Navigation("EducationGroupStream");
|
||||
|
||||
b.Navigation("StreamStudents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Student", b =>
|
||||
{
|
||||
b.Navigation("DocumentStudents");
|
||||
|
||||
b.Navigation("StudentStream");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Disciplines");
|
||||
|
||||
b.Navigation("Documents");
|
||||
|
||||
b.Navigation("EducationGroups");
|
||||
|
||||
b.Navigation("EducationStatuses");
|
||||
|
||||
b.Navigation("Streams");
|
||||
|
||||
b.Navigation("Students");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class nullableEdStatusId5 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_EducationStatuses_User_UserId",
|
||||
table: "EducationStatuses");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Students_User_UserId",
|
||||
table: "Students");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_EducationStatuses_User_UserId",
|
||||
table: "EducationStatuses",
|
||||
column: "UserId",
|
||||
principalTable: "User",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Students_User_UserId",
|
||||
table: "Students",
|
||||
column: "UserId",
|
||||
principalTable: "User",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_EducationStatuses_User_UserId",
|
||||
table: "EducationStatuses");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Students_User_UserId",
|
||||
table: "Students");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_EducationStatuses_User_UserId",
|
||||
table: "EducationStatuses",
|
||||
column: "UserId",
|
||||
principalTable: "User",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Students_User_UserId",
|
||||
table: "Students",
|
||||
column: "UserId",
|
||||
principalTable: "User",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -107,44 +107,34 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupDocument", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("EducationGroupId")
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("EducationGroupId", "DocumentId");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("EducationGroupId");
|
||||
|
||||
b.ToTable("EducationGroupsDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroupStream", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasIndex("EducationGroupId");
|
||||
b.HasKey("EducationGroupId", "StreamId");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
@ -237,47 +227,37 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentDocument", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("StudentId", "DocumentId");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("StudentId", "StreamId");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentStreams");
|
||||
});
|
||||
|
||||
@ -314,7 +294,7 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.WithMany("Disciplines")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -327,9 +307,9 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Document", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.WithMany("Documents")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
@ -338,7 +318,7 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.WithMany("EducationGroups")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -387,9 +367,9 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationStatus", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.WithMany("EducationStatuses")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
@ -398,7 +378,7 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.WithMany("Streams")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -413,9 +393,9 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
.HasForeignKey("EducationStatusId");
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.OnDelete(DeleteBehavior.NoAction)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("EducationStatus");
|
||||
@ -493,6 +473,21 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
|
||||
b.Navigation("StudentStream");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Disciplines");
|
||||
|
||||
b.Navigation("Documents");
|
||||
|
||||
b.Navigation("EducationGroups");
|
||||
|
||||
b.Navigation("EducationStatuses");
|
||||
|
||||
b.Navigation("Streams");
|
||||
|
||||
b.Navigation("Students");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
@ -25,27 +25,35 @@ namespace UniversityDataBaseImplemet.Models
|
||||
[ForeignKey("DocumentId")]
|
||||
public virtual List<EducationGroupDocument> EducationGroupDocument { get; set; } = new();
|
||||
public virtual User User { get; set; }
|
||||
private Dictionary<int, IStudentModel>? _studentDocument = null;
|
||||
private List<StudentViewModel>? _documentStudents = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IStudentModel> StudentDocument
|
||||
public List<StudentViewModel> DocumentStudents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_studentDocument == null)
|
||||
if (_documentStudents == null)
|
||||
{
|
||||
_studentDocument = Students.ToDictionary(rec => rec.StudentId, rec => rec.Student as IStudentModel);
|
||||
_documentStudents = Students.Select(x => new StudentViewModel(x.Student)).ToList();
|
||||
}
|
||||
return _studentDocument;
|
||||
return _documentStudents;
|
||||
}
|
||||
}
|
||||
public static Document? Create(DocumentBindingModel model)
|
||||
public static Document? Create(Database context, DocumentBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Document()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Date = model.Date,
|
||||
UserId = model.UserId,
|
||||
Students = model.DocumentStudents.Select(x => new StudentDocument()
|
||||
{
|
||||
Student = context.Students.First(y => y.Id == x.Id),
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(DocumentBindingModel model)
|
||||
@ -60,34 +68,26 @@ namespace UniversityDataBaseImplemet.Models
|
||||
}
|
||||
public void UpdateStudents(Database context, DocumentBindingModel model)
|
||||
{
|
||||
var studentDocument = context.StudentDocuments
|
||||
.Where(rec => rec.DocumentId == model.Id)
|
||||
.ToList();
|
||||
if (studentDocument != null)
|
||||
var documentStudents = context.StudentDocuments.Where(x => x.DocumentId == model.Id).ToList();
|
||||
List<int> currentStudents = documentStudents.Select(x => x.StudentId).ToList();
|
||||
List<int> modelStudents = model.DocumentStudents.Select(x => x.Id).ToList();
|
||||
if (documentStudents != null && documentStudents.Count > 0)
|
||||
{
|
||||
context.StudentDocuments
|
||||
.RemoveRange(studentDocument
|
||||
.Where(rec => !model.StudentDocument
|
||||
.ContainsKey(rec.StudentId))
|
||||
);
|
||||
context.StudentDocuments.RemoveRange(documentStudents.Where(x => !modelStudents.Contains(x.StudentId)));
|
||||
model.DocumentStudents.RemoveAll(x => currentStudents.Contains(x.Id));
|
||||
context.SaveChanges();
|
||||
var document = context.Documents
|
||||
.First(x => x.Id == Id);
|
||||
foreach (var sd in studentDocument)
|
||||
{
|
||||
model.StudentDocument.Remove(sd.StudentId);
|
||||
}
|
||||
foreach (var sd in model.StudentDocument)
|
||||
{
|
||||
context.StudentDocuments.Add(new StudentDocument
|
||||
{
|
||||
Document = document,
|
||||
Student = context.Students.First(x => x.Id == sd.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_studentDocument = null;
|
||||
}
|
||||
var document = context.Documents.First(x => x.Id == Id);
|
||||
foreach (var record in model.DocumentStudents)
|
||||
{
|
||||
context.StudentDocuments.Add(new StudentDocument
|
||||
{
|
||||
Document = document,
|
||||
Student = context.Students.First(x => x.Id == record.Id),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_documentStudents = null;
|
||||
}
|
||||
public DocumentViewModel GetViewModel => new()
|
||||
{
|
||||
@ -95,7 +95,7 @@ namespace UniversityDataBaseImplemet.Models
|
||||
Name = Name,
|
||||
Date = Date,
|
||||
UserId = UserId,
|
||||
StudentDocument = StudentDocument
|
||||
DocumentStudents = DocumentStudents
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityModels.Models;
|
||||
using UniversityModels.Enums;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
|
||||
namespace UniversityDataBaseImplemet.Models
|
||||
{
|
||||
@ -21,7 +22,19 @@ namespace UniversityDataBaseImplemet.Models
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public Role Role { get; set; }
|
||||
public static User Create(UserBindingModel model)
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Student> Students { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Document> Documents { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<EducationStatus> EducationStatuses { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Discipline> Disciplines { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<EducationGroup> EducationGroups { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Stream> Streams { get; set; } = new();
|
||||
public static User Create(UserBindingModel model)
|
||||
{
|
||||
return new User()
|
||||
{
|
||||
|
@ -11,6 +11,5 @@ namespace UniversityModels.Models
|
||||
string Name { get; }
|
||||
DateTime Date { get; }
|
||||
int UserId { get; }
|
||||
Dictionary <int, IStudentModel> StudentDocument { get; }
|
||||
}
|
||||
}
|
||||
|
103
UniversityProvider/Controllers/DocumentController.cs
Normal file
103
UniversityProvider/Controllers/DocumentController.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityProvider.Controllers
|
||||
{
|
||||
public class DocumentController : Controller
|
||||
{
|
||||
public IActionResult Create()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create([FromBody] DocumentBindingModel documentModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
documentModel.UserId = APIClient.User.Id;
|
||||
APIClient.PostRequest("api/document/create", documentModel);
|
||||
Response.Redirect("/Home/Documents");
|
||||
}
|
||||
|
||||
public IActionResult Update(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Document = APIClient.GetRequest<DocumentViewModel>($"api/document/get?id={id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update([FromBody] DocumentBindingModel documentModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
documentModel.UserId = APIClient.User.Id;
|
||||
APIClient.PostRequest("api/document/update", documentModel);
|
||||
Response.Redirect("/Home/Documents");
|
||||
}
|
||||
|
||||
public IActionResult AddDocument(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.DocumentId = id;
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddDocument([FromBody] DocumentBindingModel documentModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
APIClient.PostRequest("api/document/update", documentModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
APIClient.PostRequest($"api/document/delete", new DocumentBindingModel() { Id = id });
|
||||
Response.Redirect("/Home/Documents");
|
||||
}
|
||||
|
||||
public List<DocumentViewModel> GetAllByUser()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<DocumentViewModel>? document = APIClient.GetRequest<List<DocumentViewModel>>($"api/document/getallbyuser?userId={APIClient.User.Id}");
|
||||
return document ?? new();
|
||||
}
|
||||
|
||||
public DocumentViewModel? Get(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
DocumentViewModel? document = APIClient.GetRequest<DocumentViewModel>($"api/document/get?id={id}");
|
||||
return document;
|
||||
}
|
||||
}
|
||||
}
|
@ -98,6 +98,24 @@ namespace UniversityProvider.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Documents(int page)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if (page == 0)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
ViewBag.Documents = APIClient.GetRequest<List<DocumentViewModel>>
|
||||
($"api/document/getmany?userId={APIClient.User.Id}&page={page}");
|
||||
ViewBag.Page = page;
|
||||
ViewBag.NumberOfPages = APIClient.GetRequest<int>
|
||||
($"api/document/getnumberofpages?userId={APIClient.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
|
38
UniversityProvider/Views/Document/Create.cshtml
Normal file
38
UniversityProvider/Views/Document/Create.cshtml
Normal file
@ -0,0 +1,38 @@
|
||||
@{
|
||||
ViewData["Title"] = "Приказ";
|
||||
}
|
||||
|
||||
<h4 class="fw-bold">Создание приказа</h4>
|
||||
|
||||
<div id="error-div-shell" class="error-div-shell mb-2">
|
||||
<div>
|
||||
<p id="error-p" class="error-p"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mb-0">Название:</p>
|
||||
<input type="text" id="name-input" name="name" class="form-control mb-3" />
|
||||
|
||||
<button id="create-button" type="button" class="button-primary text-button">
|
||||
Создать
|
||||
</button>
|
||||
|
||||
<div>
|
||||
<div class="scrollable-table">
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
<th>Фамилия</th>
|
||||
<th>Дата рождения</th>
|
||||
<th>Номер студ. билета</th>
|
||||
<th>Статус обучения</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="scrollable-table__tbody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="~/js/document/document-create.js" asp-append-version="true"></script>
|
5
UniversityProvider/Views/Document/Update.cshtml
Normal file
5
UniversityProvider/Views/Document/Update.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -1,5 +1,71 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@using UniversityContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Приказы";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Приказы</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (ViewBag.Documents == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в аккаунт</h3>
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-secondary" asp-controller="Document" asp-action="Create">Создать приказ</a>
|
||||
</div>
|
||||
<div class="d-flex mb-2 gap-1">
|
||||
<div class="input-group" style="width: auto;">
|
||||
<input id="page-input" type="number" min="1" value="@ViewBag.Page" max="@ViewBag.NumberOfPages" class="form-control" style="max-width: 5em">
|
||||
<span class="input-group-text">/ @ViewBag.NumberOfPages</span>
|
||||
</div>
|
||||
<a href="/Home/EducationStatuses?page=@ViewBag.Page" id="go-button" class="button-primary text-button">
|
||||
Перейти
|
||||
</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ViewBag.Documents)
|
||||
{
|
||||
<tr class="d-table-row">
|
||||
<td>
|
||||
@item.Name
|
||||
</td>
|
||||
<td>
|
||||
@item.Date.ToString("yyyy-MM-dd")
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Document" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
||||
</td>
|
||||
<td>
|
||||
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
<script src="~/js/documents/documents.js" asp-append-version="true"></script>
|
||||
|
@ -17,7 +17,7 @@
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-secondary" asp-controller="EducationStatus" asp-action="Create">Добавить статус обучения</a>
|
||||
<a class="btn btn-secondary" asp-controller="EducationStatus" asp-action="Create">Создать статус обучения</a>
|
||||
</div>
|
||||
<div class="d-flex mb-2 gap-1">
|
||||
<div class="input-group" style="width: auto;">
|
||||
|
@ -16,3 +16,13 @@ html {
|
||||
body {
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.scrollable-table {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.scrollable-table tr{
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
|
68
UniversityProvider/wwwroot/js/document/document-create.js
Normal file
68
UniversityProvider/wwwroot/js/document/document-create.js
Normal file
@ -0,0 +1,68 @@
|
||||
const createBtn = document.getElementById("create-button")
|
||||
const tbody = document.getElementById("scrollable-table__tbody")
|
||||
const nameInput = document.getElementById("name-input")
|
||||
var students = []
|
||||
var dataArray = [];
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
$.ajax({
|
||||
url: "/student/getallbyuser",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
students = result;
|
||||
students.forEach((student) => createRowForStudentsTable(student));
|
||||
});
|
||||
})
|
||||
|
||||
createBtn.addEventListener('click', () => {
|
||||
var document = {
|
||||
"Name": nameInput.value,
|
||||
"Date": new Date(),
|
||||
"DocumentStudents": dataArray,
|
||||
}
|
||||
$.ajax({
|
||||
url: "/document/create",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(document)
|
||||
}).done(() => {
|
||||
window.location.href = "/Home/Documents";
|
||||
});
|
||||
})
|
||||
|
||||
const createRowForStudentsTable = (student) => {
|
||||
const { id, name, surname, dateOfBirth, studentCard, educationStatusName } = student;
|
||||
const row = tbody.insertRow();
|
||||
row.setAttribute("data-id", id);
|
||||
|
||||
const cells = [name, surname, formatDate(dateOfBirth), studentCard, educationStatusName];
|
||||
cells.forEach((value) => {
|
||||
const cell = row.insertCell();
|
||||
cell.textContent = value;
|
||||
});
|
||||
|
||||
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||
};
|
||||
|
||||
const formatDate = (dateString) => {
|
||||
const date = new Date(dateString);
|
||||
const year = date.getFullYear();
|
||||
const month = ('0' + (date.getMonth() + 1)).slice(-2);
|
||||
const day = ('0' + date.getDate()).slice(-2);
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
const addAndRemoveFromList = (row) => {
|
||||
var id = parseInt(row.dataset.id);
|
||||
console.log(students.find(x => x.id === id))
|
||||
var index = dataArray.indexOf(students.find(x => x.id === id));
|
||||
if (index === -1) {
|
||||
dataArray.push(students.find(x => x.id === id));
|
||||
row.classList.add("bg-success");
|
||||
} else {
|
||||
dataArray.splice(index, 1);
|
||||
row.classList.remove("bg-success");
|
||||
}
|
||||
console.log(dataArray);
|
||||
}
|
@ -0,0 +1 @@
|
||||
|
25
UniversityProvider/wwwroot/js/document/documents.js
Normal file
25
UniversityProvider/wwwroot/js/document/documents.js
Normal file
@ -0,0 +1,25 @@
|
||||
const goToPageBtn = document.getElementById("go-button");
|
||||
const pageInput = document.getElementById("page-input");
|
||||
const removeButtons = document.querySelectorAll(".remove-btn");
|
||||
|
||||
removeButtons.forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
var id = this.dataset.id;
|
||||
|
||||
var result = confirm("Вы уверены, что хотите удалить эту запись?");
|
||||
if (result) {
|
||||
$.ajax({
|
||||
url: "/document/delete",
|
||||
type: "POST",
|
||||
data: { Id: id }
|
||||
}).done(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
pageInput.addEventListener("input", () => {
|
||||
const pageNumber = parseInt(pageInput.value);
|
||||
goToPageBtn.href = `/Home/Documents?page=${pageNumber}`;
|
||||
});
|
@ -7,29 +7,32 @@ const updateBtn = document.getElementById("update-button");
|
||||
var students = [];
|
||||
var educationStatus = null;
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
$.ajax({
|
||||
url: `/student/getallbyuserandeducationstatus?educationstatus=${educationStatusId}`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
students = result;
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const studentsResponse = await $.ajax({
|
||||
url: `/student/getallbyuserandeducationstatus?educationstatus=${educationStatusId}`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
students = studentsResponse;
|
||||
|
||||
students.forEach((student) => {
|
||||
createStudentOption(student);
|
||||
});
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: `/educationstatus/get?id=${educationStatusId}`,
|
||||
type: 'GET',
|
||||
contentType: 'json'
|
||||
}).done((result) => {
|
||||
console.log(result);
|
||||
educationStatus = result;
|
||||
const educationStatusResponse = await $.ajax({
|
||||
url: `/educationstatus/get?id=${educationStatusId}`,
|
||||
type: 'GET',
|
||||
contentType: 'json'
|
||||
});
|
||||
educationStatus = educationStatusResponse;
|
||||
fillEducationStatusInput(educationStatus);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
updateBtn.addEventListener("click", () => {
|
||||
if (select.selectedIndex === -1) {
|
||||
return;
|
||||
@ -62,54 +65,58 @@ const fillEducationStatusInput = (educationStatus) => {
|
||||
|
||||
select.addEventListener("change", () => {
|
||||
studentTable.innerHTML = "";
|
||||
const trName = document.createElement('tr');
|
||||
const trSurname = document.createElement('tr');
|
||||
const trStudentCard = document.createElement('tr');
|
||||
|
||||
const createRow = (label, value) => {
|
||||
const tr = document.createElement('tr');
|
||||
const tdLabel = document.createElement('td');
|
||||
tdLabel.innerHTML = label;
|
||||
const tdValue = document.createElement('td');
|
||||
tdValue.innerHTML = value;
|
||||
|
||||
tr.appendChild(tdLabel);
|
||||
tr.appendChild(document.createElement('td'));
|
||||
tr.appendChild(document.createElement('td'));
|
||||
tr.appendChild(tdValue);
|
||||
|
||||
return tr;
|
||||
};
|
||||
|
||||
const student = students.find(x => x.id === parseInt(select.value));
|
||||
|
||||
const formattedDate = formatDate(student.dateOfBirth);
|
||||
|
||||
const trName = createRow("Имя:", student.name);
|
||||
const trSurname = createRow("Фамилия:", student.surname);
|
||||
const trBirthdate = createRow("Дата рождения:", formattedDate);
|
||||
const trStudentCard = createRow("Номер студ. билета:", student.studentCard);
|
||||
|
||||
const trEducationStatusName = document.createElement('tr');
|
||||
|
||||
var student = students.find(x => x.id === parseInt(select.value));
|
||||
|
||||
const tdNameField = document.createElement('td');
|
||||
tdNameField.innerHTML = "Имя:";
|
||||
const tdSurnameField = document.createElement('td');
|
||||
tdSurnameField.innerHTML = "Фамилия:";
|
||||
const tdStudentCardField = document.createElement('td');
|
||||
tdStudentCardField.innerHTML = "Номер студ. билета:";
|
||||
const tdEducationStatusNameField = document.createElement('td');
|
||||
tdEducationStatusNameField.innerHTML = "Статус обучения:";
|
||||
|
||||
const tdNewEducationStatusName = document.createElement('td');
|
||||
tdNewEducationStatusName.innerHTML = educationStatus.name;
|
||||
const tdArrowEducationStatusName = document.createElement('td');
|
||||
tdArrowEducationStatusName.innerHTML = "--->"
|
||||
const tdName = document.createElement('td');
|
||||
tdName.innerHTML = student.name;
|
||||
const tdSurname = document.createElement('td');
|
||||
tdSurname.innerHTML = student.surname;
|
||||
const tdStudentCard = document.createElement('td');
|
||||
tdStudentCard.innerHTML = student.studentCard;
|
||||
const tdEducationStatusName = document.createElement('td');
|
||||
tdEducationStatusName.innerHTML = student.educationStatusName;
|
||||
tdArrowEducationStatusName.innerHTML = "-->";
|
||||
const tdEducationStatusName = createRow("", student.educationStatusName);
|
||||
|
||||
trName.appendChild(tdNameField);
|
||||
trName.appendChild(document.createElement('td'));
|
||||
trName.appendChild(document.createElement('td'));
|
||||
trName.appendChild(tdName);
|
||||
trSurname.appendChild(tdSurnameField);
|
||||
trSurname.appendChild(document.createElement('td'));
|
||||
trSurname.appendChild(document.createElement('td'));
|
||||
trSurname.appendChild(tdSurname);
|
||||
trStudentCard.appendChild(tdStudentCardField);
|
||||
trStudentCard.appendChild(document.createElement('td'));
|
||||
trStudentCard.appendChild(document.createElement('td'));
|
||||
trStudentCard.appendChild(tdStudentCard);
|
||||
trEducationStatusName.appendChild(tdEducationStatusNameField);
|
||||
trEducationStatusName.appendChild(tdNewEducationStatusName);
|
||||
trEducationStatusName.appendChild(tdArrowEducationStatusName);
|
||||
trEducationStatusName.appendChild(tdEducationStatusName);
|
||||
|
||||
studentTable.appendChild(trName);
|
||||
studentTable.appendChild(trSurname);
|
||||
studentTable.appendChild(trStudentCard);
|
||||
studentTable.appendChild(trEducationStatusName);
|
||||
})
|
||||
studentTable.append(
|
||||
trName,
|
||||
trSurname,
|
||||
trBirthdate,
|
||||
trStudentCard,
|
||||
trEducationStatusName
|
||||
);
|
||||
});
|
||||
|
||||
const formatDate = (dateString) => {
|
||||
const date = new Date(dateString);
|
||||
const year = date.getFullYear();
|
||||
const month = ('0' + (date.getMonth() + 1)).slice(-2);
|
||||
const day = ('0' + date.getDate()).slice(-2);
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
@ -1,12 +1,111 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityRestAPI.Controllers
|
||||
{
|
||||
public class DocumentController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class DocumentController : Controller
|
||||
{
|
||||
private readonly IDocumentLogic _documentLogic;
|
||||
|
||||
public DocumentController(IDocumentLogic documentLogic)
|
||||
{
|
||||
_documentLogic = documentLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public DocumentViewModel? Get(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _documentLogic.ReadElement(new DocumentSearchModel { Id = id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<DocumentViewModel>? GetAllByUser(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _documentLogic.ReadList(new DocumentSearchModel { UserId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<DocumentViewModel>? GetMany(int userId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _documentLogic.ReadList(new DocumentSearchModel { UserId = userId, PageNumber = page, PageSize = 10 });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public int GetNumberOfPages(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _documentLogic.GetNumberOfPages(userId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(DocumentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_documentLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(DocumentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_documentLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(DocumentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_documentLogic.Delete(new() { Id = model.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace UniversityRestAPI.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _educationStatusLogic.ReadList(null);
|
||||
return _educationStatusLogic.ReadList(new EducationStatusSearchModel { UserId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user