student crud
This commit is contained in:
parent
295dc0ad1d
commit
91212b9254
@ -71,7 +71,12 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(StudentBindingModel model, bool withParams = true)
|
||||
public int GetNumberOfPages(int userId, int pageSize = 10)
|
||||
{
|
||||
return _studentStorage.GetNumberOfPages(userId, pageSize);
|
||||
}
|
||||
|
||||
private void CheckModel(StudentBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -83,9 +88,17 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия документа", nameof(model.Name));
|
||||
throw new ArgumentNullException("Нет имени студента", nameof(model.Name));
|
||||
}
|
||||
if (model.StudentCard <= 0)
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет фамилии студента", nameof(model.Name));
|
||||
}
|
||||
if (model.DateOfBirth > DateTime.UtcNow)
|
||||
{
|
||||
throw new ArgumentNullException("Неверно указана дата рождения студента", nameof(model.Name));
|
||||
}
|
||||
if (model.StudentCard <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Неверно указан номер студенческого билета", nameof(model.Name));
|
||||
}
|
||||
@ -96,7 +109,7 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
});
|
||||
if (student != null && student.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Приказ с таким названием уже есть");
|
||||
throw new InvalidOperationException("Студент с таким номером студенческого билета уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace UniversityContracts.BindingModels
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
public int StudentCard { get; set; }
|
||||
public int EducationStatusId { get; set; }
|
||||
public int? EducationStatusId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -16,5 +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);
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,8 @@ namespace UniversityContracts.SearchModels
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public bool? Disciplines { get; set; }
|
||||
}
|
||||
|
||||
public int? PageNumber { get; set; }
|
||||
public int? PageSize { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace UniversityContracts.StoragesContracts
|
||||
StudentViewModel? Insert(StudentBindingModel model);
|
||||
StudentViewModel? Update(StudentBindingModel model);
|
||||
StudentViewModel? Delete(StudentBindingModel model);
|
||||
}
|
||||
public int GetNumberOfPages(int userId, int pageSize);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,6 @@ namespace UniversityContracts.ViewModels
|
||||
[DisplayName("Статус обучения")]
|
||||
public string EducationStatusName { get; set; } = string.Empty;
|
||||
public int StudentCard { get; set; }
|
||||
public int EducationStatusId { get; set; }
|
||||
public int? EducationStatusId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -18,22 +18,38 @@ namespace UniversityDataBaseImplemet.Implements
|
||||
{
|
||||
public StudentViewModel? GetElement(StudentSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && model.StudentCard <= 0)
|
||||
using var context = new Database();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Students
|
||||
.Include(record => record.User)
|
||||
.Include(record => record.EducationStatus)
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id)
|
||||
|| record.StudentCard.Equals(model.StudentCard))
|
||||
?.GetViewModel;
|
||||
return context.Students
|
||||
.Include(record => record.User)
|
||||
.Include(record => record.EducationStatus)
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
else if (model.StudentCard.HasValue)
|
||||
{
|
||||
return context.Students
|
||||
.Include(record => record.User)
|
||||
.Include(record => record.EducationStatus)
|
||||
.FirstOrDefault(record => record.StudentCard.Equals(model.StudentCard))
|
||||
?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public List<StudentViewModel> GetFilteredList(StudentSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
if (model.Id.HasValue)
|
||||
if (model.UserId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue)
|
||||
{
|
||||
return context.Students
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Skip(model.PageSize.Value * (model.PageNumber.Value - 1))
|
||||
.Take(model.PageSize.Value)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.Id.HasValue)
|
||||
{
|
||||
return context.Students
|
||||
.Include(record => record.User)
|
||||
@ -117,5 +133,13 @@ namespace UniversityDataBaseImplemet.Implements
|
||||
context.SaveChanges();
|
||||
return student.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
504
UniversityDataBaseImplemet/Migrations/20230517093341_nullableEdStatusId.Designer.cs
generated
Normal file
504
UniversityDataBaseImplemet/Migrations/20230517093341_nullableEdStatusId.Designer.cs
generated
Normal file
@ -0,0 +1,504 @@
|
||||
// <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("20230517093341_nullableEdStatusId")]
|
||||
partial class nullableEdStatusId
|
||||
{
|
||||
/// <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>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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.HasIndex("EducationGroupId");
|
||||
|
||||
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>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
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()
|
||||
.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()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class nullableEdStatusId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
505
UniversityDataBaseImplemet/Migrations/20230517094848_nullableEdStatusId2.Designer.cs
generated
Normal file
505
UniversityDataBaseImplemet/Migrations/20230517094848_nullableEdStatusId2.Designer.cs
generated
Normal file
@ -0,0 +1,505 @@
|
||||
// <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("20230517094848_nullableEdStatusId2")]
|
||||
partial class nullableEdStatusId2
|
||||
{
|
||||
/// <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>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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.HasIndex("EducationGroupId");
|
||||
|
||||
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")
|
||||
.IsRequired()
|
||||
.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>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
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()
|
||||
.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()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class nullableEdStatusId2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
502
UniversityDataBaseImplemet/Migrations/20230517095031_nullableEdStatusId3.Designer.cs
generated
Normal file
502
UniversityDataBaseImplemet/Migrations/20230517095031_nullableEdStatusId3.Designer.cs
generated
Normal file
@ -0,0 +1,502 @@
|
||||
// <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("20230517095031_nullableEdStatusId3")]
|
||||
partial class nullableEdStatusId3
|
||||
{
|
||||
/// <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>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("EducationGroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
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.HasIndex("EducationGroupId");
|
||||
|
||||
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>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DocumentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.StudentStream", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("StreamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StreamId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
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()
|
||||
.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()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.EducationGroup", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDataBaseImplemet.Models.Stream", b =>
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
.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()
|
||||
.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");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class nullableEdStatusId3 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Students_EducationStatuses_EducationStatusId",
|
||||
table: "Students");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "EducationStatusId",
|
||||
table: "Students",
|
||||
type: "integer",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Students_EducationStatuses_EducationStatusId",
|
||||
table: "Students",
|
||||
column: "EducationStatusId",
|
||||
principalTable: "EducationStatuses",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Students_EducationStatuses_EducationStatusId",
|
||||
table: "Students");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "EducationStatusId",
|
||||
table: "Students",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Students_EducationStatuses_EducationStatusId",
|
||||
table: "Students",
|
||||
column: "EducationStatusId",
|
||||
principalTable: "EducationStatuses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -209,7 +209,7 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("EducationStatusId")
|
||||
b.Property<int?>("EducationStatusId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
@ -410,9 +410,7 @@ namespace UniversityDataBaseImplemet.Migrations
|
||||
{
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.EducationStatus", "EducationStatus")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("EducationStatusId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("EducationStatusId");
|
||||
|
||||
b.HasOne("UniversityDataBaseImplemet.Models.User", "User")
|
||||
.WithMany()
|
||||
|
@ -22,15 +22,15 @@ namespace UniversityDataBaseImplemet.Models
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
[Required]
|
||||
public int StudentCard { get; set; }
|
||||
[Required]
|
||||
public int EducationStatusId { get; set; }
|
||||
|
||||
public int? EducationStatusId { get; set; }
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
[ForeignKey("StudentId")]
|
||||
public virtual List<StudentDocument> DocumentStudents { get; set; } = new();
|
||||
[ForeignKey("StudentId")]
|
||||
public virtual List<StudentStream> StudentStream { get; set; } = new();
|
||||
public virtual EducationStatus EducationStatus { get; set; }
|
||||
public virtual EducationStatus? EducationStatus { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
|
||||
public static Student Create(StudentBindingModel model)
|
||||
@ -48,6 +48,9 @@ namespace UniversityDataBaseImplemet.Models
|
||||
}
|
||||
public void Update(StudentBindingModel model)
|
||||
{
|
||||
Name = model.Name;
|
||||
Surname = model.Surname;
|
||||
DateOfBirth = model.DateOfBirth;
|
||||
StudentCard = model.StudentCard;
|
||||
EducationStatusId = model.EducationStatusId;
|
||||
}
|
||||
@ -60,7 +63,7 @@ namespace UniversityDataBaseImplemet.Models
|
||||
StudentCard = StudentCard,
|
||||
EducationStatusId = EducationStatusId,
|
||||
UserId = UserId,
|
||||
EducationStatusName = EducationStatus.Name
|
||||
EducationStatusName = EducationStatus?.Name ?? "Не указан"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace UniversityModels.Models
|
||||
string Surname { get; }
|
||||
DateTime DateOfBirth { get; }
|
||||
int StudentCard { get; }
|
||||
int EducationStatusId { get; }
|
||||
int? EducationStatusId { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,25 @@ namespace UniversityProvider.Controllers
|
||||
return;
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Students(int page)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if (page == 0)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
ViewBag.Students = APIClient.GetRequest<List<StudentViewModel>>
|
||||
($"api/student/getmany?userId={APIClient.User.Id}&page={page}");
|
||||
ViewBag.Page = page;
|
||||
ViewBag.NumberOfPages = APIClient.GetRequest<int>
|
||||
($"api/student/getnumberofpages?userId={APIClient.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
|
85
UniversityProvider/Controllers/StudentController.cs
Normal file
85
UniversityProvider/Controllers/StudentController.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityProvider.Controllers
|
||||
{
|
||||
public class StudentController : Controller
|
||||
{
|
||||
public IActionResult Create()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create([FromBody] StudentBindingModel studentModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
studentModel.UserId = APIClient.User.Id;
|
||||
studentModel.EducationStatusId = null;
|
||||
APIClient.PostRequest("api/student/create", studentModel);
|
||||
Response.Redirect("/Home/Students");
|
||||
}
|
||||
|
||||
public IActionResult Update(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Student = APIClient.GetRequest<StudentViewModel>($"api/student/get?id={id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update([FromBody] StudentBindingModel studentModel)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
studentModel.UserId = APIClient.User.Id;
|
||||
APIClient.PostRequest("api/student/update", studentModel);
|
||||
Response.Redirect("/Home/Students");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
APIClient.PostRequest($"api/student/delete", new StudentBindingModel() { Id = id });
|
||||
Response.Redirect("/Home/Students");
|
||||
}
|
||||
|
||||
public List<StudentViewModel> GetAllByUser()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<StudentViewModel>? students = APIClient.GetRequest<List<StudentViewModel>>($"api/student/getallbyuser?userId={APIClient.User.Id}");
|
||||
return students ?? new();
|
||||
}
|
||||
|
||||
|
||||
public StudentViewModel? Get(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
StudentViewModel? student = APIClient.GetRequest<StudentViewModel>($"api/student/get?id={id}");
|
||||
return student;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
@model List<StudentViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Студенты";
|
||||
@ -12,17 +11,23 @@
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
if (ViewBag.Students == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в аккаунт</h3>
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-secondary" asp-action="Student">Добавить</a>
|
||||
<a class="btn btn-secondary" asp-action="Student">Изменить</a>
|
||||
<a class="btn btn-secondary" asp-action="Student">Удалить</a>
|
||||
<a class="btn btn-secondary" asp-action="Student">Обновить</a>
|
||||
<a class="btn btn-secondary" asp-controller="Student" 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/Students?page=@ViewBag.Page" id="go-button" class="button-primary text-button">
|
||||
Перейти
|
||||
</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -38,27 +43,41 @@
|
||||
<th>
|
||||
Статус обучения
|
||||
</th>
|
||||
<th>
|
||||
Изменить запись
|
||||
</th>
|
||||
<th>
|
||||
Удалить запись
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
@foreach (var item in ViewBag.Students)
|
||||
{
|
||||
<tr>
|
||||
<tr class="d-table-row">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name + ' ' + item.Surname)
|
||||
@item.Name @item.Surname
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOfBirth)
|
||||
@item.DateOfBirth.ToString("yyyy-MM-dd")
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.StudentCard)
|
||||
@item.StudentCard
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EducationStatusId)
|
||||
@item.EducationStatusName
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Student" 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>
|
||||
</div>
|
||||
|
||||
<script src="~/js/student/students.js" asp-append-version="true"></script>
|
||||
|
@ -44,12 +44,6 @@
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2023 - UniversityProvider - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
26
UniversityProvider/Views/Student/Create.cshtml
Normal file
26
UniversityProvider/Views/Student/Create.cshtml
Normal file
@ -0,0 +1,26 @@
|
||||
@{
|
||||
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" />
|
||||
<p class="mb-0">Фамилия:</p>
|
||||
<input type="text" id="surname-input" name="surname" class="form-control mb-3" />
|
||||
<p class="mb-0">Дата рождения:</p>
|
||||
<input type="date" id="date-input" name="date" class="form-control mb-3" />
|
||||
<p class="mb-0">Номер студенческого билета:</p>
|
||||
<input type="text" id="studcard-input" name="studcard" class="form-control mb-3" />
|
||||
|
||||
<button id="create-button" type="button" class="button-primary text-button">
|
||||
Создать
|
||||
</button>
|
||||
|
||||
<script src="~/js/student/student-create.js" asp-append-version="true"></script>
|
36
UniversityProvider/Views/Student/Update.cshtml
Normal file
36
UniversityProvider/Views/Student/Update.cshtml
Normal file
@ -0,0 +1,36 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Студент";
|
||||
}
|
||||
|
||||
@{
|
||||
|
||||
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Student.Id">Изменение данных студента</h4>
|
||||
|
||||
if (ViewBag.Student == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в аккаунт</h3>
|
||||
return;
|
||||
}
|
||||
<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 value="@ViewBag.Student.Name" type="text" id="name-input" name="name" class="form-control mb-3" />
|
||||
<p class="mb-0">Фамилия:</p>
|
||||
<input value="@ViewBag.Student.Surname" type="text" id="surname-input" name="surname" class="form-control mb-3" />
|
||||
<p class="mb-0">Дата рождения:</p>
|
||||
<input value="@ViewBag.Student.DateOfBirth.ToString("yyyy-MM-dd")" type="date" id="date-input" name="date" class="form-control mb-3" />
|
||||
<p class="mb-0">Номер студенческого билета:</p>
|
||||
<input value="@ViewBag.Student.StudentCard" type="text" id="studcard-input" name="studcard" class="form-control mb-3" />
|
||||
|
||||
<button id="update-button" type="button" class="button-primary text-button">
|
||||
Сохранить изменения
|
||||
</button>
|
||||
}
|
||||
|
||||
<script src="~/js/student/student-update.js" asp-append-version="true"></script>
|
42
UniversityProvider/wwwroot/js/student/student-create.js
Normal file
42
UniversityProvider/wwwroot/js/student/student-create.js
Normal file
@ -0,0 +1,42 @@
|
||||
const createBtn = document.getElementById("create-button");
|
||||
const nameInput = document.getElementById("name-input")
|
||||
const surnameInput = document.getElementById("surname-input")
|
||||
const dateInput = document.getElementById("date-input")
|
||||
const studCardInput = document.getElementById("studcard-input")
|
||||
|
||||
createBtn.addEventListener("click", () => {
|
||||
if (!correctData()) {
|
||||
return;
|
||||
}
|
||||
if (!validate()) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
const correctData = function () {
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const validate = function () {
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
createBtn.addEventListener("click", () => {
|
||||
let student = {
|
||||
"Name": nameInput.value,
|
||||
"Surname": surnameInput.value,
|
||||
"DateOfBirth": new Date(dateInput.value),
|
||||
"StudentCard": parseInt(studCardInput.value),
|
||||
};
|
||||
console.log(student)
|
||||
$.ajax({
|
||||
url: `/student/create`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(student)
|
||||
}).done(() => {
|
||||
window.location.href = "/Home/Students";
|
||||
});
|
||||
});
|
45
UniversityProvider/wwwroot/js/student/student-update.js
Normal file
45
UniversityProvider/wwwroot/js/student/student-update.js
Normal file
@ -0,0 +1,45 @@
|
||||
const updateBtn = document.getElementById("update-button");
|
||||
const nameInput = document.getElementById("name-input")
|
||||
const surnameInput = document.getElementById("surname-input")
|
||||
const dateInput = document.getElementById("date-input")
|
||||
const studCardInput = document.getElementById("studcard-input")
|
||||
const studId = document.getElementById("vb-id").dataset.id
|
||||
|
||||
updateBtn.addEventListener("click", () => {
|
||||
if (!correctData()) {
|
||||
return;
|
||||
}
|
||||
if (!validate()) {
|
||||
return;
|
||||
}
|
||||
form.submit();
|
||||
});
|
||||
|
||||
const correctData = function () {
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const validate = function () {
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
updateBtn.addEventListener("click", () => {
|
||||
let student = {
|
||||
"Id": parseInt(studId),
|
||||
"Name": nameInput.value,
|
||||
"Surname": surnameInput.value,
|
||||
"DateOfBirth": new Date(dateInput.value),
|
||||
"StudentCard": parseInt(studCardInput.value),
|
||||
};
|
||||
console.log(student)
|
||||
$.ajax({
|
||||
url: `/student/update`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(student)
|
||||
}).done(() => {
|
||||
window.location.href = "/Home/Students";
|
||||
});
|
||||
});
|
25
UniversityProvider/wwwroot/js/student/students.js
Normal file
25
UniversityProvider/wwwroot/js/student/students.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: `/student/delete`,
|
||||
type: 'POST',
|
||||
data: { Id: id }
|
||||
}).done(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
pageInput.addEventListener("input", () => {
|
||||
const pageNumber = parseInt(pageInput.value);
|
||||
goToPageBtn.href = `/Home/Students?page=${pageNumber}`;
|
||||
});
|
12
UniversityRestAPI/Controllers/DocumentController.cs
Normal file
12
UniversityRestAPI/Controllers/DocumentController.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace UniversityRestAPI.Controllers
|
||||
{
|
||||
public class DocumentController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
12
UniversityRestAPI/Controllers/EducationStatusController.cs
Normal file
12
UniversityRestAPI/Controllers/EducationStatusController.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace UniversityRestAPI.Controllers
|
||||
{
|
||||
public class EducationStatusController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
111
UniversityRestAPI/Controllers/StudentController.cs
Normal file
111
UniversityRestAPI/Controllers/StudentController.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityRestAPI.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class StudentController : Controller
|
||||
{
|
||||
private readonly IStudentLogic _studentLogic;
|
||||
|
||||
public StudentController(IStudentLogic studentLogic)
|
||||
{
|
||||
_studentLogic = studentLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public StudentViewModel? Get(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _studentLogic.ReadElement(new StudentSearchModel { Id = id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<StudentViewModel>? GetAllByUser(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _studentLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<StudentViewModel>? GetMany(int userId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _studentLogic.ReadList(new StudentSearchModel { UserId = userId, PageNumber = page, PageSize = 10 });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public int GetNumberOfPages(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _studentLogic.GetNumberOfPages(userId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(StudentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_studentLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(StudentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_studentLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(StudentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_studentLogic.Delete(new() { Id = model.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,8 +8,14 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||
builder.Services.AddTransient<IStudentStorage, StudentStorage>();
|
||||
builder.Services.AddTransient<IEducationStatusStorage, EducationStatusStorage>();
|
||||
builder.Services.AddTransient<IDocumentStorage, DocumentStorage>();
|
||||
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
builder.Services.AddTransient<IStudentLogic, StudentLogic>();
|
||||
builder.Services.AddTransient<IEducationStatusLogic, EducationStatusLogic>();
|
||||
builder.Services.AddTransient<IDocumentLogic, DocumentLogic>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user