все crud сделаны. Привязка из нескольких записей групп для приказа сделана. Привязка из одной записи студента для статуса обучения сделана.
Остались отчеты, возможно графики и дезигн
This commit is contained in:
parent
7e3706b2f6
commit
bc6d955ad4
@ -4,13 +4,14 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UniversityContracts.BindingModels;
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
using UniversityContracts.SearchModels;
|
using UniversityContracts.SearchModels;
|
||||||
using UniversityContracts.StoragesContracts;
|
using UniversityContracts.StoragesContracts;
|
||||||
using UniversityContracts.ViewModels;
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
namespace UniversityBusinessLogic.BusinessLogics
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class EducationGroupLogic
|
public class EducationGroupLogic : IEducationGroupLogic
|
||||||
{
|
{
|
||||||
private readonly IEducationGroupStorage _egStorage;
|
private readonly IEducationGroupStorage _egStorage;
|
||||||
|
|
||||||
|
@ -15,5 +15,6 @@ namespace UniversityContracts.BindingModels
|
|||||||
public DateTime Date { get; set; } = DateTime.Now;
|
public DateTime Date { get; set; } = DateTime.Now;
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
public List<StudentViewModel> DocumentStudents { get; set; } = new();
|
public List<StudentViewModel> DocumentStudents { get; set; } = new();
|
||||||
|
public List<EducationGroupViewModel> DocumentGroups { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@ namespace UniversityContracts.ViewModels
|
|||||||
[DisplayName("Дата создания документа")]
|
[DisplayName("Дата создания документа")]
|
||||||
public DateTime Date { get; set; } = DateTime.Now;
|
public DateTime Date { get; set; } = DateTime.Now;
|
||||||
public List<StudentViewModel> DocumentStudents { get; set; } = new();
|
public List<StudentViewModel> DocumentStudents { get; set; } = new();
|
||||||
|
public List<EducationGroupViewModel> DocumentEdGroups { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,27 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using UniversityModels.Models;
|
||||||
|
|
||||||
namespace UniversityContracts.ViewModels
|
namespace UniversityContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class EducationGroupViewModel
|
public class EducationGroupViewModel : IEducationGroupModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название группы")]
|
[DisplayName("Название группы")]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество студентов в группе")]
|
[DisplayName("Количество студентов в группе")]
|
||||||
public int NumberOfStudents { get; set; }
|
public int NumberOfStudent { get; set; }
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
public EducationGroupViewModel() { }
|
||||||
|
|
||||||
|
public EducationGroupViewModel(IEducationGroupModel model)
|
||||||
|
{
|
||||||
|
Id = model.Id;
|
||||||
|
UserId = model.UserId;
|
||||||
|
Name = model.Name;
|
||||||
|
NumberOfStudent = model.NumberOfStudent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,8 @@ namespace UniversityDataBaseImplemet.Implements
|
|||||||
.Include(record => record.User)
|
.Include(record => record.User)
|
||||||
.Include(record => record.Students)
|
.Include(record => record.Students)
|
||||||
.ThenInclude(record => record.Student)
|
.ThenInclude(record => record.Student)
|
||||||
|
.Include(record => record.EducationGroupDocument)
|
||||||
|
.ThenInclude(record => record.EducationGroup)
|
||||||
.FirstOrDefault(record => record.Id == model.Id
|
.FirstOrDefault(record => record.Id == model.Id
|
||||||
|| record.Name.Equals(model.Name))
|
|| record.Name.Equals(model.Name))
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
@ -113,6 +115,7 @@ namespace UniversityDataBaseImplemet.Implements
|
|||||||
document.Update(model);
|
document.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
document.UpdateStudents(context, model);
|
document.UpdateStudents(context, model);
|
||||||
|
document.UpdateGroups(context, model);
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
return document.GetViewModel;
|
return document.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -127,6 +130,7 @@ namespace UniversityDataBaseImplemet.Implements
|
|||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
var document = context.Documents
|
var document = context.Documents
|
||||||
.Include(record => record.User)
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.Students)
|
||||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
if (document == null)
|
if (document == null)
|
||||||
{
|
{
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UniversityContracts.BindingModels;
|
using UniversityContracts.BindingModels;
|
||||||
using UniversityContracts.SearchModels;
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
using UniversityContracts.ViewModels;
|
using UniversityContracts.ViewModels;
|
||||||
using UniversityDataBaseImplemet.Models;
|
using UniversityDataBaseImplemet.Models;
|
||||||
|
|
||||||
namespace UniversityDataBaseImplemet.Implements
|
namespace UniversityDataBaseImplemet.Implements
|
||||||
{
|
{
|
||||||
public class EducationGroupStorage
|
public class EducationGroupStorage : IEducationGroupStorage
|
||||||
{
|
{
|
||||||
public EducationGroupViewModel? GetElement(EducationGroupSearchModel model)
|
public EducationGroupViewModel? GetElement(EducationGroupSearchModel model)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,6 @@ namespace UniversityDataBaseImplemet.Implements
|
|||||||
{
|
{
|
||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
return context.EducationStatuses
|
return context.EducationStatuses
|
||||||
.Include(record => record.User)
|
|
||||||
.Select(record => record.GetViewModel)
|
.Select(record => record.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -108,6 +107,7 @@ namespace UniversityDataBaseImplemet.Implements
|
|||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
var educationStatus = context.EducationStatuses
|
var educationStatus = context.EducationStatuses
|
||||||
.Include(record => record.User)
|
.Include(record => record.User)
|
||||||
|
.Include(record => record.Students)
|
||||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||||
if (educationStatus == null)
|
if (educationStatus == null)
|
||||||
{
|
{
|
||||||
|
485
UniversityDataBaseImplemet/Migrations/20230518085846_fix.Designer.cs
generated
Normal file
485
UniversityDataBaseImplemet/Migrations/20230518085846_fix.Designer.cs
generated
Normal file
@ -0,0 +1,485 @@
|
|||||||
|
// <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("20230518085846_fix")]
|
||||||
|
partial class fix
|
||||||
|
{
|
||||||
|
/// <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.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.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.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.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
UniversityDataBaseImplemet/Migrations/20230518085846_fix.cs
Normal file
62
UniversityDataBaseImplemet/Migrations/20230518085846_fix.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace UniversityDataBaseImplemet.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class fix : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Id",
|
||||||
|
table: "StudentStreams");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Id",
|
||||||
|
table: "StudentDocuments");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Id",
|
||||||
|
table: "EducationGroupsStreams");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Id",
|
||||||
|
table: "EducationGroupsDocuments");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "Id",
|
||||||
|
table: "StudentStreams",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "Id",
|
||||||
|
table: "StudentDocuments",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "Id",
|
||||||
|
table: "EducationGroupsStreams",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "Id",
|
||||||
|
table: "EducationGroupsDocuments",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -113,9 +113,6 @@ namespace UniversityDataBaseImplemet.Migrations
|
|||||||
b.Property<int>("DocumentId")
|
b.Property<int>("DocumentId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("EducationGroupId", "DocumentId");
|
b.HasKey("EducationGroupId", "DocumentId");
|
||||||
|
|
||||||
b.HasIndex("DocumentId");
|
b.HasIndex("DocumentId");
|
||||||
@ -131,9 +128,6 @@ namespace UniversityDataBaseImplemet.Migrations
|
|||||||
b.Property<int>("StreamId")
|
b.Property<int>("StreamId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("EducationGroupId", "StreamId");
|
b.HasKey("EducationGroupId", "StreamId");
|
||||||
|
|
||||||
b.HasIndex("StreamId");
|
b.HasIndex("StreamId");
|
||||||
@ -233,9 +227,6 @@ namespace UniversityDataBaseImplemet.Migrations
|
|||||||
b.Property<int>("DocumentId")
|
b.Property<int>("DocumentId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("StudentId", "DocumentId");
|
b.HasKey("StudentId", "DocumentId");
|
||||||
|
|
||||||
b.HasIndex("DocumentId");
|
b.HasIndex("DocumentId");
|
||||||
@ -251,9 +242,6 @@ namespace UniversityDataBaseImplemet.Migrations
|
|||||||
b.Property<int>("StreamId")
|
b.Property<int>("StreamId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("StudentId", "StreamId");
|
b.HasKey("StudentId", "StreamId");
|
||||||
|
|
||||||
b.HasIndex("StreamId");
|
b.HasIndex("StreamId");
|
||||||
|
@ -38,6 +38,19 @@ namespace UniversityDataBaseImplemet.Models
|
|||||||
return _documentStudents;
|
return _documentStudents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private List<EducationGroupViewModel>? _documentEdGroups = null;
|
||||||
|
[NotMapped]
|
||||||
|
public List<EducationGroupViewModel> DocumentEdGroups
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_documentEdGroups == null)
|
||||||
|
{
|
||||||
|
_documentEdGroups = EducationGroupDocument.Select(x => new EducationGroupViewModel(x.EducationGroup)).ToList();
|
||||||
|
}
|
||||||
|
return _documentEdGroups;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static Document? Create(Database context, DocumentBindingModel? model)
|
public static Document? Create(Database context, DocumentBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -89,13 +102,37 @@ namespace UniversityDataBaseImplemet.Models
|
|||||||
}
|
}
|
||||||
_documentStudents = null;
|
_documentStudents = null;
|
||||||
}
|
}
|
||||||
|
public void UpdateGroups(Database context, DocumentBindingModel model)
|
||||||
|
{
|
||||||
|
var documentGroups = context.EducationGroupsDocuments.Where(x => x.DocumentId == model.Id).ToList();
|
||||||
|
List<int> currentGroups = documentGroups.Select(x => x.EducationGroupId).ToList();
|
||||||
|
List<int> modelGroups = model.DocumentGroups.Select(x => x.Id).ToList();
|
||||||
|
if (documentGroups != null && documentGroups.Count > 0)
|
||||||
|
{
|
||||||
|
context.EducationGroupsDocuments.RemoveRange(documentGroups.Where(x => !modelGroups.Contains(x.EducationGroupId)));
|
||||||
|
model.DocumentGroups.RemoveAll(x => currentGroups.Contains(x.Id));
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
var document = context.Documents.First(x => x.Id == Id);
|
||||||
|
foreach (var record in model.DocumentGroups)
|
||||||
|
{
|
||||||
|
context.EducationGroupsDocuments.Add(new EducationGroupDocument
|
||||||
|
{
|
||||||
|
Document = document,
|
||||||
|
EducationGroup = context.EducationGroups.First(x => x.Id == record.Id),
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_documentEdGroups = null;
|
||||||
|
}
|
||||||
public DocumentViewModel GetViewModel => new()
|
public DocumentViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Date = Date,
|
Date = Date,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
DocumentStudents = DocumentStudents
|
DocumentStudents = DocumentStudents,
|
||||||
|
DocumentEdGroups = DocumentEdGroups,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace UniversityDataBaseImplemet.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
Name = Name,
|
Name = Name,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
NumberOfStudents= NumberOfStudent
|
NumberOfStudent = NumberOfStudent
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ namespace UniversityDataBaseImplemet.Models
|
|||||||
{
|
{
|
||||||
public class EducationGroupDocument
|
public class EducationGroupDocument
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
[Required]
|
[Required]
|
||||||
public int EducationGroupId { get; set; }
|
public int EducationGroupId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -9,7 +9,6 @@ namespace UniversityDataBaseImplemet.Models
|
|||||||
{
|
{
|
||||||
public class EducationGroupStream
|
public class EducationGroupStream
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
[Required]
|
[Required]
|
||||||
public int EducationGroupId { get; set; }
|
public int EducationGroupId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -9,7 +9,6 @@ namespace UniversityDataBaseImplemet.Models
|
|||||||
{
|
{
|
||||||
public class StudentDocument
|
public class StudentDocument
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
[Required]
|
[Required]
|
||||||
public int StudentId { get; set; }
|
public int StudentId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -9,7 +9,6 @@ namespace UniversityDataBaseImplemet.Models
|
|||||||
{
|
{
|
||||||
public class StudentStream
|
public class StudentStream
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
[Required]
|
[Required]
|
||||||
public int StudentId { get; set; }
|
public int StudentId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -69,6 +69,26 @@ namespace UniversityProvider.Controllers
|
|||||||
APIClient.PostRequest("api/document/update", documentModel);
|
APIClient.PostRequest("api/document/update", documentModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult Bind(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 Bind([FromBody] DocumentBindingModel documentModel)
|
||||||
|
{
|
||||||
|
if (APIClient.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("403");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/document/update", documentModel);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
@ -90,6 +110,16 @@ namespace UniversityProvider.Controllers
|
|||||||
return document ?? new();
|
return document ?? new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<EducationGroupViewModel> GetAllGroups()
|
||||||
|
{
|
||||||
|
if (APIClient.User == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
List<EducationGroupViewModel>? group = APIClient.GetRequest<List<EducationGroupViewModel>>("api/document/GetAllGroups");
|
||||||
|
return group ?? new();
|
||||||
|
}
|
||||||
|
|
||||||
public DocumentViewModel? Get(int id)
|
public DocumentViewModel? Get(int id)
|
||||||
{
|
{
|
||||||
if (APIClient.User == null)
|
if (APIClient.User == null)
|
||||||
|
35
UniversityProvider/Views/Document/Bind.cshtml
Normal file
35
UniversityProvider/Views/Document/Bind.cshtml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Приказ";
|
||||||
|
}
|
||||||
|
|
||||||
|
@{
|
||||||
|
<h4 id="document-data" class="fw-bold" data-id="@ViewBag.Document.Id">Привязка группы к приказу</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" readonly value="@ViewBag.Document.Name" 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>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="scrollable-table__tbody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<script src="~/js/document/document-bind.js" asp-append-version="true"></script>
|
@ -1,5 +1,39 @@
|
|||||||
@*
|
@{
|
||||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
ViewData["Title"] = "Приказ";
|
||||||
*@
|
|
||||||
@{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@{
|
||||||
|
<h4 id="document-data" class="fw-bold" data-id="@ViewBag.Document.Id">Обновление приказа</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" value="@ViewBag.Document.Name" 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-update.js" asp-append-version="true"></script>
|
@ -55,6 +55,9 @@
|
|||||||
<td>
|
<td>
|
||||||
@item.Date.ToString("yyyy-MM-dd")
|
@item.Date.ToString("yyyy-MM-dd")
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Document" asp-action="Bind" asp-route-id="@item.Id">Привязка</a>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Document" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Document" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
||||||
</td>
|
</td>
|
||||||
@ -68,4 +71,4 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="~/js/documents/documents.js" asp-append-version="true"></script>
|
<script src="~/js/document/documents.js" asp-append-version="true"></script>
|
||||||
|
84
UniversityProvider/wwwroot/js/document/document-bind.js
Normal file
84
UniversityProvider/wwwroot/js/document/document-bind.js
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
const createBtn = document.getElementById("create-button");
|
||||||
|
const tbody = document.getElementById("scrollable-table__tbody");
|
||||||
|
const nameInput = document.getElementById("name-input");
|
||||||
|
const currentDocumentId = document.getElementById("document-data").dataset.id;
|
||||||
|
var groups = [];
|
||||||
|
var dataArray = [];
|
||||||
|
var currentDocument = null;
|
||||||
|
|
||||||
|
window.addEventListener('load', async () => {
|
||||||
|
await $.ajax({
|
||||||
|
url: "/document/getallgroups",
|
||||||
|
type: "GET",
|
||||||
|
contentType: "json"
|
||||||
|
}).done((result) => {
|
||||||
|
groups = result;
|
||||||
|
console.log(groups)
|
||||||
|
});
|
||||||
|
await $.ajax({
|
||||||
|
url: `/document/get?id=${currentDocumentId}`,
|
||||||
|
type: "GET",
|
||||||
|
contentType: "json"
|
||||||
|
}).done((result) => {
|
||||||
|
currentDocument = result;
|
||||||
|
console.log(currentDocument)
|
||||||
|
});
|
||||||
|
groups.forEach((group) => createRowForGroupsTable(group));
|
||||||
|
})
|
||||||
|
|
||||||
|
createBtn.addEventListener('click', () => {
|
||||||
|
var documentGroupsUpdate = {
|
||||||
|
"Id": currentDocument.id,
|
||||||
|
"Name": currentDocument.name,
|
||||||
|
"Date": currentDocument.date,
|
||||||
|
"DocumentStudents": currentDocument.documentStudents,
|
||||||
|
"DocumentGroups": dataArray,
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: "/document/update",
|
||||||
|
type: "POST",
|
||||||
|
contentType: "application/json",
|
||||||
|
data: JSON.stringify(documentGroupsUpdate)
|
||||||
|
}).done(() => {
|
||||||
|
window.location.href = "/Home/Documents";
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
const createRowForGroupsTable = (group) => {
|
||||||
|
const { id, name } = group;
|
||||||
|
const row = tbody.insertRow();
|
||||||
|
row.setAttribute("data-id", id);
|
||||||
|
|
||||||
|
const cells = [name];
|
||||||
|
cells.forEach((value) => {
|
||||||
|
const cell = row.insertCell();
|
||||||
|
cell.textContent = value;
|
||||||
|
});
|
||||||
|
console.log(currentDocument)
|
||||||
|
if (currentDocument.documentEdGroups?.find(x => parseInt(x.id) === parseInt(group.id))) {
|
||||||
|
row.classList.add("bg-success");
|
||||||
|
dataArray.push(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
var index = dataArray.indexOf(groups.find(x => x.id === id));
|
||||||
|
if (index === -1) {
|
||||||
|
dataArray.push(groups.find(x => x.id === id));
|
||||||
|
row.classList.add("bg-success");
|
||||||
|
} else {
|
||||||
|
dataArray.splice(index, 1);
|
||||||
|
row.classList.remove("bg-success");
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,82 @@
|
|||||||
|
const createBtn = document.getElementById("create-button");
|
||||||
|
const tbody = document.getElementById("scrollable-table__tbody");
|
||||||
|
const nameInput = document.getElementById("name-input");
|
||||||
|
const currentDocumentId = document.getElementById("document-data").dataset.id;
|
||||||
|
var students = [];
|
||||||
|
var dataArray = [];
|
||||||
|
var currentDocument = null;
|
||||||
|
|
||||||
|
window.addEventListener('load', async () => {
|
||||||
|
await $.ajax({
|
||||||
|
url: "/student/getallbyuser",
|
||||||
|
type: "GET",
|
||||||
|
contentType: "json"
|
||||||
|
}).done((result) => {
|
||||||
|
students = result;
|
||||||
|
});
|
||||||
|
await $.ajax({
|
||||||
|
url: `/document/get?id=${currentDocumentId}`,
|
||||||
|
type: "GET",
|
||||||
|
contentType: "json"
|
||||||
|
}).done((result) => {
|
||||||
|
currentDocument = result;
|
||||||
|
});
|
||||||
|
students.forEach((student) => createRowForStudentsTable(student));
|
||||||
|
})
|
||||||
|
|
||||||
|
createBtn.addEventListener('click', () => {
|
||||||
|
var documentGroupsUpdate = {
|
||||||
|
"Id": currentDocument.id,
|
||||||
|
"Name": nameInput.value,
|
||||||
|
"Date": currentDocument.date,
|
||||||
|
"DocumentStudents": dataArray,
|
||||||
|
"DocumentGroups": currentDocument.documentEdGroups,
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: "/document/update",
|
||||||
|
type: "POST",
|
||||||
|
contentType: "application/json",
|
||||||
|
data: JSON.stringify(documentGroupsUpdate)
|
||||||
|
}).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;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (currentDocument.documentStudents.find(x => parseInt(x.id) === parseInt(student.id))) {
|
||||||
|
row.classList.add("bg-success");
|
||||||
|
dataArray.push(student);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
@ -2,10 +2,12 @@
|
|||||||
const pageInput = document.getElementById("page-input");
|
const pageInput = document.getElementById("page-input");
|
||||||
const removeButtons = document.querySelectorAll(".remove-btn");
|
const removeButtons = document.querySelectorAll(".remove-btn");
|
||||||
|
|
||||||
|
console.log(removeButtons)
|
||||||
|
|
||||||
removeButtons.forEach(function (button) {
|
removeButtons.forEach(function (button) {
|
||||||
button.addEventListener("click", function (event) {
|
button.addEventListener("click", function (event) {
|
||||||
var id = this.dataset.id;
|
var id = this.dataset.id;
|
||||||
|
console.log(id)
|
||||||
var result = confirm("Вы уверены, что хотите удалить эту запись?");
|
var result = confirm("Вы уверены, что хотите удалить эту запись?");
|
||||||
if (result) {
|
if (result) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -11,10 +11,13 @@ namespace UniversityRestAPI.Controllers
|
|||||||
public class DocumentController : Controller
|
public class DocumentController : Controller
|
||||||
{
|
{
|
||||||
private readonly IDocumentLogic _documentLogic;
|
private readonly IDocumentLogic _documentLogic;
|
||||||
|
private readonly IEducationGroupLogic _edGroupLogic;
|
||||||
|
|
||||||
public DocumentController(IDocumentLogic documentLogic)
|
public DocumentController(IDocumentLogic documentLogic,
|
||||||
|
IEducationGroupLogic edGroupLogic)
|
||||||
{
|
{
|
||||||
_documentLogic = documentLogic;
|
_documentLogic = documentLogic;
|
||||||
|
_edGroupLogic = edGroupLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -56,6 +59,19 @@ namespace UniversityRestAPI.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<EducationGroupViewModel>? GetAllGroups()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _edGroupLogic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public int GetNumberOfPages(int userId)
|
public int GetNumberOfPages(int userId)
|
||||||
{
|
{
|
||||||
|
@ -11,11 +11,13 @@ builder.Services.AddTransient<IUserStorage, UserStorage>();
|
|||||||
builder.Services.AddTransient<IStudentStorage, StudentStorage>();
|
builder.Services.AddTransient<IStudentStorage, StudentStorage>();
|
||||||
builder.Services.AddTransient<IEducationStatusStorage, EducationStatusStorage>();
|
builder.Services.AddTransient<IEducationStatusStorage, EducationStatusStorage>();
|
||||||
builder.Services.AddTransient<IDocumentStorage, DocumentStorage>();
|
builder.Services.AddTransient<IDocumentStorage, DocumentStorage>();
|
||||||
|
builder.Services.AddTransient<IEducationGroupStorage, EducationGroupStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||||
builder.Services.AddTransient<IStudentLogic, StudentLogic>();
|
builder.Services.AddTransient<IStudentLogic, StudentLogic>();
|
||||||
builder.Services.AddTransient<IEducationStatusLogic, EducationStatusLogic>();
|
builder.Services.AddTransient<IEducationStatusLogic, EducationStatusLogic>();
|
||||||
builder.Services.AddTransient<IDocumentLogic, DocumentLogic>();
|
builder.Services.AddTransient<IDocumentLogic, DocumentLogic>();
|
||||||
|
builder.Services.AddTransient<IEducationGroupLogic, EducationGroupLogic>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user