diff --git a/School/School.sln b/School/School.sln index 218fc09..dc165ee 100644 --- a/School/School.sln +++ b/School/School.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchoolContracts", "SchoolCo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchoolBusinessLogic", "SchoolBusinessLogic\SchoolBusinessLogic.csproj", "{E78D42A3-7FA0-4E3A-B0C8-AEC70B3EE331}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchoolDatabaseImplement", "SchoolDatabaseImplement\SchoolDatabaseImplement.csproj", "{8C8F56D4-E267-498F-AFCD-06701962D09F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {E78D42A3-7FA0-4E3A-B0C8-AEC70B3EE331}.Debug|Any CPU.Build.0 = Debug|Any CPU {E78D42A3-7FA0-4E3A-B0C8-AEC70B3EE331}.Release|Any CPU.ActiveCfg = Release|Any CPU {E78D42A3-7FA0-4E3A-B0C8-AEC70B3EE331}.Release|Any CPU.Build.0 = Release|Any CPU + {8C8F56D4-E267-498F-AFCD-06701962D09F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C8F56D4-E267-498F-AFCD-06701962D09F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C8F56D4-E267-498F-AFCD-06701962D09F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C8F56D4-E267-498F-AFCD-06701962D09F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/School/SchoolApp/SchoolApp.csproj b/School/SchoolApp/SchoolApp.csproj index c78c9c7..1d1d459 100644 --- a/School/SchoolApp/SchoolApp.csproj +++ b/School/SchoolApp/SchoolApp.csproj @@ -6,4 +6,11 @@ enable + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/School/SchoolContracts/BindingModels/InterestBindingModel.cs b/School/SchoolContracts/BindingModels/InterestBindingModel.cs index a78d981..1b7adc3 100644 --- a/School/SchoolContracts/BindingModels/InterestBindingModel.cs +++ b/School/SchoolContracts/BindingModels/InterestBindingModel.cs @@ -12,7 +12,7 @@ namespace SchoolContracts.BindingModels public int Id { get; set; } public string Name { get; set; } = string.Empty; public string Direction { get; set; } = string.Empty; - public string Discription { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; public Dictionary InterestLessons { get; diff --git a/School/SchoolContracts/ViewModels/InterestViewModel.cs b/School/SchoolContracts/ViewModels/InterestViewModel.cs index e40fb53..5ee4e08 100644 --- a/School/SchoolContracts/ViewModels/InterestViewModel.cs +++ b/School/SchoolContracts/ViewModels/InterestViewModel.cs @@ -16,7 +16,7 @@ namespace SchoolContracts.ViewModels [DisplayName("Направление интереса")] public string Direction { get; set; } = string.Empty; [DisplayName("Описание интереса")] - public string Discription { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; public Dictionary InterestLessons { get; diff --git a/School/SchoolContracts/ViewModels/LessonViewModel.cs b/School/SchoolContracts/ViewModels/LessonViewModel.cs index 5ec7104..43d9fd8 100644 --- a/School/SchoolContracts/ViewModels/LessonViewModel.cs +++ b/School/SchoolContracts/ViewModels/LessonViewModel.cs @@ -12,6 +12,8 @@ namespace SchoolContracts.ViewModels { public int Id { get; set; } public int UserId { get; set; } + [DisplayName("Пользователь")] + public string UserName { get; set; } = string.Empty; [DisplayName("Время начала занятие")] public DateTime TimeStart { get; set; } [DisplayName("Время конца занятия")] diff --git a/School/SchoolDatabaseImplement/Models/Achievement.cs b/School/SchoolDatabaseImplement/Models/Achievement.cs new file mode 100644 index 0000000..47df7b1 --- /dev/null +++ b/School/SchoolDatabaseImplement/Models/Achievement.cs @@ -0,0 +1,61 @@ +using SchoolContracts.BindingModels; +using SchoolContracts.ViewModels; +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDatabaseImplement.Models +{ + public class Achievement : IAchievementModel + { + public int Id { get; private set; } + [Required] + public int LessonId { get; private set; } + public virtual Lesson? Lesson { get; private set; } + [Required] + public string Name { get; private set; } = string.Empty; + + public string Description { get; private set; } = string.Empty; + + public DateTime ReceiptDate { get; private set; } + public static Achievement? Create(AchievementBindingModel model) + { + if (model == null) + { + return null; + } + return new Achievement() + { + Id = model.Id, + LessonId = model.LessonId, + Name = model.Name, + Description = model.Description, + ReceiptDate = model.ReceiptDate + }; + } + public void Update(AchievementBindingModel model) + { + if (model == null) + { + return; + } + Name = model.Name; + Description = model.Description; + ReceiptDate = model.ReceiptDate; + } + public AchievementViewModel GetViewModel => new() + { + Id = Id, + LessonId = LessonId, + Name = Name, + Description = Description, + ReceiptDate = ReceiptDate + }; + + + } +} diff --git a/School/SchoolDatabaseImplement/Models/Interest.cs b/School/SchoolDatabaseImplement/Models/Interest.cs new file mode 100644 index 0000000..fe0679c --- /dev/null +++ b/School/SchoolDatabaseImplement/Models/Interest.cs @@ -0,0 +1,63 @@ +using SchoolContracts.BindingModels; +using SchoolContracts.ViewModels; +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDatabaseImplement.Models +{ + public class Interest : IInterestModel + { + public int Id { get; private set; } + [Required] + public string Name { get; private set; } = string.Empty; + [Required] + public string Direction { get; private set; } = string.Empty; + + public string Description { get; private set; } = string.Empty; + [ForeignKey("InterestId")] + public virtual List InterestLessons { get; set; } = new(); + [Required] + + + Dictionary IInterestModel.InterestLessons => throw new NotImplementedException(); + public static Interest? Create(InterestBindingModel model) + { + if (model == null) + { + return null; + } + return new Interest() + { + Id = model.Id, + Name = model.Name, + Direction = model.Direction, + Description = model.Description + }; + } + public void Update(InterestBindingModel model) + { + if (model == null) + { + return; + } + Name = model.Name; + Direction = model.Direction; + Description = model.Description; + } + public InterestViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + Direction = Direction, + Description = Description + }; + + + } +} diff --git a/School/SchoolDatabaseImplement/Models/InterestLesson.cs b/School/SchoolDatabaseImplement/Models/InterestLesson.cs new file mode 100644 index 0000000..833fb5a --- /dev/null +++ b/School/SchoolDatabaseImplement/Models/InterestLesson.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDatabaseImplement.Models +{ + public class InterestLesson + { + public int Id { get; set; } + [Required] + public int InterestId { get; set; } + [Required] + public int LessonId { get; set; } + [Required] + public virtual Lesson Lesson { get; set; } = new(); + public virtual Interest Interest { get; set; } = new(); + + } +} diff --git a/School/SchoolDatabaseImplement/Models/Lesson.cs b/School/SchoolDatabaseImplement/Models/Lesson.cs new file mode 100644 index 0000000..e697536 --- /dev/null +++ b/School/SchoolDatabaseImplement/Models/Lesson.cs @@ -0,0 +1,60 @@ +using SchoolContracts.BindingModels; +using SchoolContracts.ViewModels; +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDatabaseImplement.Models +{ + public class Lesson : ILessonModel + { + public int Id { get; private set; } + [Required] + public DateTime TimeStart { get; private set; } + [Required] + public DateTime TimeEnd { get; private set; } + [ForeignKey("LessonId")] + public virtual List InterestLessons { get; set; } = new(); + [Required] + public int UserId { get; private set; } + public virtual User? User { get; private set; } + public static Lesson? Create(LessonBindingModel model) + { + if (model == null) + { + return null; + } + return new Lesson() + { + Id = model.Id, + UserId = model.UserId, + TimeStart = model.TimeStart, + TimeEnd = model.TimeEnd + }; + } + public void Update(LessonBindingModel model) + { + if (model == null) + { + return; + } + TimeStart = model.TimeStart; + TimeEnd = model.TimeEnd; + } + public LessonViewModel GetViewModel => new() + { + UserId = UserId, + TimeStart = TimeStart, + TimeEnd = TimeEnd, + Id = Id, + UserName = User?.Name ?? string.Empty + }; + + + } +} diff --git a/School/SchoolDatabaseImplement/Models/User.cs b/School/SchoolDatabaseImplement/Models/User.cs new file mode 100644 index 0000000..c8522b9 --- /dev/null +++ b/School/SchoolDatabaseImplement/Models/User.cs @@ -0,0 +1,68 @@ +using SchoolContracts.BindingModels; +using SchoolContracts.ViewModels; +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +namespace SchoolDatabaseImplement.Models +{ + public class User : IUserModel + { + public int Id { get; private set; } + [Required] + public string Name { get; private set; } = string.Empty; + [Required] + public DateTime BirthDate { get; private set; } + public string Mail { get; private set; } = string.Empty; + + public string PhoneNumber { get; private set; } = string.Empty; + + public string Password { get; private set; } = string.Empty; + public static User? Create(UserBindingModel model) + { + if (model == null) + { + return null; + } + return new User() + { + Id = model.Id, + Name = model.Name, + BirthDate = model.BirthDate, + Mail = model.Mail, + PhoneNumber = model.PhoneNumber, + Password = model.Password + }; + } + + public void Update(UserBindingModel model) + { + if (model == null) + { + return; + } + Name = model.Name; + BirthDate = model.BirthDate; + Mail = model.Mail; + PhoneNumber = model.PhoneNumber; + Password = model.Password; + } + public UserViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + BirthDate = BirthDate, + Mail = Mail, + PhoneNumber = PhoneNumber, + Password = Password + }; + + + } +} diff --git a/School/SchoolDatabaseImplement/SchoolDatabaseImplement.csproj b/School/SchoolDatabaseImplement/SchoolDatabaseImplement.csproj new file mode 100644 index 0000000..18d83ea --- /dev/null +++ b/School/SchoolDatabaseImplement/SchoolDatabaseImplement.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/School/SchoolsDataModels/Models/IInterestModel.cs b/School/SchoolsDataModels/Models/IInterestModel.cs index 21e882f..7c2acd5 100644 --- a/School/SchoolsDataModels/Models/IInterestModel.cs +++ b/School/SchoolsDataModels/Models/IInterestModel.cs @@ -12,7 +12,7 @@ namespace SchoolDataModels.Models string Direction { get; } - string Discription { get; } + string Description { get; } Dictionary InterestLessons { get; } }