diff --git a/OutOfSchool/OutOfSchool.Common/Models/CodeficatorAddressDto.cs b/OutOfSchool/OutOfSchool.Common/Models/CodeficatorAddressDto.cs index 1d533df4ab..002786e008 100644 --- a/OutOfSchool/OutOfSchool.Common/Models/CodeficatorAddressDto.cs +++ b/OutOfSchool/OutOfSchool.Common/Models/CodeficatorAddressDto.cs @@ -14,6 +14,8 @@ public class CodeficatorAddressDto public string Settlement { get; set; } + public string CityDistrict { get; set; } + public double Latitude { get; set; } public double Longitude { get; set; } @@ -22,7 +24,12 @@ public string FullName { get { - string addr = Settlement; + string addr = CityDistrict; + + if (!string.IsNullOrEmpty(Settlement)) + { + addr += GetSplitter(addr) + Settlement; + } if (!string.IsNullOrEmpty(TerritorialCommunity)) { diff --git a/OutOfSchool/OutOfSchool.DataAccess/Enums/CodeficatorCategory.cs b/OutOfSchool/OutOfSchool.DataAccess/Enums/CodeficatorCategory.cs index 5420cdfa2a..7d521c9926 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Enums/CodeficatorCategory.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Enums/CodeficatorCategory.cs @@ -2,30 +2,170 @@ namespace OutOfSchool.Services.Enums; -public sealed class CodeficatorCategory : SmartEnum +public abstract class CodeficatorCategory : SmartEnum { - public static readonly CodeficatorCategory Region = new ("O", 1); // Автономна Республіка Крим, області. - public static readonly CodeficatorCategory SpecialStatusCity = new ("K", 2); // Міста, що мають спеціальний статус. - public static readonly CodeficatorCategory Level1 = new ("OK", 3); // Автономна Республіка Крим, області та міста, що мають спеціальний статус. + public static readonly CodeficatorCategory Region = new RegionCategory(); // Автономна Республіка Крим, області. - public static readonly CodeficatorCategory District = new ("P", 4); // Райони в областях та Автономній Республіці Крим. + public static readonly CodeficatorCategory SpecialStatusCity = new SpecialStatusCityCategory(); // Міста, що мають спеціальний статус. - public static readonly CodeficatorCategory TerritorialCommunity = new ("H", 8); // Території територіальних громад (назви територіальних громад) в областях, територіальні громади Автономної Республіки Крим. - public static readonly CodeficatorCategory Level3 = new ("H", 8); // Території територіальних громад (назви територіальних громад) в областях, територіальні громади Автономної Республіки Крим. + public static readonly CodeficatorCategory District = new DistrictCategory(); // Райони в областях та Автономній Республіці Крим. - public static readonly CodeficatorCategory City = new ("M", 16); // Міста. - public static readonly CodeficatorCategory UrbanSettlement = new ("T", 32); // Селища міського типу. - public static readonly CodeficatorCategory Village = new ("C", 64); // Села. - public static readonly CodeficatorCategory Settlement = new ("X", 128); // Селища. - public static readonly CodeficatorCategory Level4 = new ("MTCX", 208); // Міста, селища міського типу, села та селища + public static readonly CodeficatorCategory TerritorialCommunity = new TerritorialCommunityCategory(); // Території територіальних громад (назви територіальних громад) в областях, територіальні громади Автономної Республіки Крим. - public static readonly CodeficatorCategory CityDistrict = new ("B", 256); // Райони в містах. - public static readonly CodeficatorCategory Level2 = new ("PB", 260); // Райони в областях та Автономній Республіці Крим та райони в містах. + public static readonly CodeficatorCategory City = new CityCategory(); // Міста. - public static readonly CodeficatorCategory SearchableCategories = new ("MTCXK", 210); // Міста, що мають спеціальний статус, міста, селища міського типу, села та селища + public static readonly CodeficatorCategory UrbanSettlement = new UrbanSettlementCategory(); // Селища міського типу. + + public static readonly CodeficatorCategory Village = new VillageCategory(); // Села. + + public static readonly CodeficatorCategory Settlement = new SettlementCategory(); // Селища. + + public static readonly CodeficatorCategory CityDistrict = new CityDistrictCategory(); // Райони в містах. + + public static readonly CodeficatorCategory Level1 = new Level1Category(); // Автономна Республіка Крим, області та міста, що мають спеціальний статус. + + public static readonly CodeficatorCategory Level2 = new Level2Category(); // Райони в областях та Автономній Республіці Крим та райони в містах. + + public static readonly CodeficatorCategory Level4 = new Level4Category(); // Міста, селища міського типу, села та селища + + public static readonly CodeficatorCategory SearchableCategories = new SearchableCategoriesCategory(); // Міста, що мають спеціальний статус, міста, селища міського типу, села та селища private CodeficatorCategory(string name, int value) : base(name, value) { } + + public abstract string Abbrivation { get; } + + private sealed class RegionCategory : CodeficatorCategory + { + public RegionCategory() + : base("O", 1) + { + } + + public override string Abbrivation => "обл."; + } + + private sealed class SpecialStatusCityCategory : CodeficatorCategory + { + public SpecialStatusCityCategory() + : base("K", 2) + { + } + + public override string Abbrivation => "м."; + } + + private sealed class DistrictCategory : CodeficatorCategory + { + public DistrictCategory() + : base("P", 4) + { + } + + public override string Abbrivation => "р-н"; + } + + private sealed class TerritorialCommunityCategory : CodeficatorCategory + { + public TerritorialCommunityCategory() + : base("H", 8) + { + } + + public override string Abbrivation => "отг"; + } + + private sealed class CityCategory : CodeficatorCategory + { + public CityCategory() + : base("M", 16) + { + } + + public override string Abbrivation => "м."; + } + + private sealed class UrbanSettlementCategory : CodeficatorCategory + { + public UrbanSettlementCategory() + : base("T", 32) + { + } + + public override string Abbrivation => "смт"; + } + + private sealed class VillageCategory : CodeficatorCategory + { + public VillageCategory() + : base("C", 64) + { + } + + public override string Abbrivation => "с."; + } + + private sealed class SettlementCategory : CodeficatorCategory + { + public SettlementCategory() + : base("X", 128) + { + } + + public override string Abbrivation => "с-ще"; + } + + private sealed class CityDistrictCategory : CodeficatorCategory + { + public CityDistrictCategory() + : base("B", 258) + { + } + + public override string Abbrivation => "р-н"; + } + + // Group (flag) values + + private sealed class Level1Category : CodeficatorCategory + { + public Level1Category() + : base("OK", 3) + { + } + + public override string Abbrivation => string.Empty; + } + + private sealed class Level2Category : CodeficatorCategory + { + public Level2Category() + : base("PB", 260) + { + } + + public override string Abbrivation => string.Empty; + } + + private sealed class Level4Category : CodeficatorCategory + { + public Level4Category() + : base("MTCX", 208) + { + } + + public override string Abbrivation => string.Empty; + } + + private sealed class SearchableCategoriesCategory : CodeficatorCategory + { + public SearchableCategoriesCategory() + : base("MTCXK", 210) + { + } + + public override string Abbrivation => string.Empty; + } } \ No newline at end of file diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/Address.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/Address.cs index 40a977115c..1d89908463 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/Address.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/Address.cs @@ -36,6 +36,10 @@ public class Address : IKeyedEntity // parameter r means size (resolution) of hexagon public ulong GeoHash => Api.GeoToH3(default(GeoCoord).SetDegrees((decimal)Latitude, (decimal)Longitude), GeoMathHelper.Resolution); + public long CodeficatorId { get; set; } + + public virtual Codeficator Codeficator { get; set; } + public override bool Equals(object obj) { if (obj == null) diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220720094332_AddressAddCodeficatorId.Designer.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220720094332_AddressAddCodeficatorId.Designer.cs new file mode 100644 index 0000000000..8bdb73dbcf --- /dev/null +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220720094332_AddressAddCodeficatorId.Designer.cs @@ -0,0 +1,2442 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using OutOfSchool.Services; + +#nullable disable + +namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations +{ + [DbContext(typeof(OutOfSchoolDbContext))] + [Migration("20220720094332_AddressAddCodeficatorId")] + partial class AddressAddCodeficatorId + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("AchievementChild", b => + { + b.Property("AchievementsId") + .HasColumnType("binary(16)"); + + b.Property("ChildrenId") + .HasColumnType("binary(16)"); + + b.HasKey("AchievementsId", "ChildrenId"); + + b.HasIndex("ChildrenId"); + + b.ToTable("AchievementChild"); + }); + + modelBuilder.Entity("DirectionInstitutionHierarchy", b => + { + b.Property("DirectionsId") + .HasColumnType("bigint"); + + b.Property("InstitutionHierarchiesId") + .HasColumnType("binary(16)"); + + b.HasKey("DirectionsId", "InstitutionHierarchiesId"); + + b.HasIndex("InstitutionHierarchiesId"); + + b.ToTable("DirectionInstitutionHierarchy"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FriendlyName") + .HasColumnType("longtext"); + + b.Property("Xml") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("RoleId") + .HasColumnType("varchar(255)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Achievement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AchievementDate") + .HasColumnType("date"); + + b.Property("AchievementTypeId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("AchievementTypeId"); + + b.HasIndex("WorkshopId"); + + b.ToTable("Achievements"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AchievementTeacher", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AchievementId") + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("AchievementId"); + + b.ToTable("AchievementTeachers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AchievementType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("AchievementTypes"); + + b.HasData( + new + { + Id = 1L, + Title = "Переможці міжнародних та всеукраїнських спортивних змагань (індивідуальних та командних)" + }, + new + { + Id = 2L, + Title = "Призери та учасники міжнародних, всеукраїнських та призери регіональних конкурсів і виставок наукових, технічних, дослідницьких, інноваційних, ІТ проектів" + }, + new + { + Id = 3L, + Title = "Реципієнти міжнародних грантів" + }, + new + { + Id = 4L, + Title = "Призери міжнародних культурних конкурсів та фестивалів" + }, + new + { + Id = 5L, + Title = "Соціально активні категорії учнів" + }, + new + { + Id = 6L, + Title = "Цифрові інструменти Google для закладів вищої та фахової передвищої освіти" + }, + new + { + Id = 7L, + Title = "Переможці та учасники олімпіад міжнародного та всеукраїнського рівнів" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BuildingNumber") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("varchar(15)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CodeficatorId") + .HasColumnType("bigint"); + + b.Property("District") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("Region") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Street") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("CodeficatorId"); + + b.ToTable("Addresses"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Application", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("ApprovedTime") + .HasColumnType("datetime(6)"); + + b.Property("ChildId") + .HasColumnType("binary(16)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("IsBlocked") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("RejectionMessage") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Status") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("ChildId"); + + b.HasIndex("ParentId"); + + b.HasIndex("WorkshopId"); + + b.ToTable("Applications"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.BlockedProviderParent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("DateTimeFrom") + .HasColumnType("datetime(6)"); + + b.Property("DateTimeTo") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("UserIdBlock") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserIdUnblock") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProviderId"); + + b.ToTable("BlockedProviderParents"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChangesLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("EntityIdGuid") + .HasColumnType("binary(16)"); + + b.Property("EntityIdLong") + .HasColumnType("bigint"); + + b.Property("EntityType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("NewValue") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("OldValue") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PropertyName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("ChangesLog"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatMessageWorkshop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("ChatRoomId") + .HasColumnType("binary(16)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("ReadDateTime") + .HasColumnType("datetime(6)"); + + b.Property("SenderRoleIsProvider") + .HasColumnType("tinyint(1)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("ChatRoomId"); + + b.ToTable("ChatMessageWorkshops"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatRoomWorkshop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("IsBlocked") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("WorkshopId"); + + b.ToTable("ChatRoomWorkshops"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Child", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Gender") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("MiddleName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("PlaceOfStudy") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Children"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChildSocialGroup", b => + { + b.Property("ChildId") + .HasColumnType("binary(16)"); + + b.Property("SocialGroupId") + .HasColumnType("bigint"); + + b.HasKey("ChildId", "SocialGroupId"); + + b.HasIndex("SocialGroupId"); + + b.ToTable("ChildrenSocialGroups"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.City", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("District") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("GeoHash") + .HasColumnType("bigint unsigned"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("Name") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Region") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.HasKey("Id"); + + b.ToTable("Cities"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Class", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DepartmentId") + .HasColumnType("bigint"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.HasKey("Id"); + + b.HasIndex("DepartmentId"); + + b.ToTable("Classes"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Codeficator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Category") + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("Code") + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("GeoHash") + .HasColumnType("bigint unsigned"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("Name") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("NeedCheck") + .HasColumnType("tinyint(1)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Codeficators"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.CompanyInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("CompanyInformation"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.CompanyInformationItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("CompanyInformationId") + .HasColumnType("binary(16)"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("SectionName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CompanyInformationId"); + + b.ToTable("CompanyInformationItems"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.DateTimeRange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("EndTime") + .HasColumnType("time(6)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("StartTime") + .HasColumnType("time(6)"); + + b.Property("Workdays") + .HasColumnType("tinyint unsigned"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("WorkshopId"); + + b.ToTable("DateTimeRanges"); + + b.HasCheckConstraint("CK_DateTimeRanges_EndTimeIsAfterStartTime", "EndTime >= StartTime"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Department", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("DirectionId") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.HasKey("Id"); + + b.HasIndex("DirectionId"); + + b.ToTable("Departments"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Direction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Directions"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ElasticsearchSyncRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Entity") + .HasColumnType("int"); + + b.Property("Operation") + .HasColumnType("int"); + + b.Property("OperationDate") + .HasColumnType("datetime(6)"); + + b.Property("RecordId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.ToTable("ElasticsearchSyncRecords"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Favorite", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("WorkshopId"); + + b.ToTable("Favorites"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Images.Image", b => + { + b.Property("EntityId") + .HasColumnType("binary(16)"); + + b.Property("ExternalStorageId") + .HasColumnType("varchar(255)"); + + b.HasKey("EntityId", "ExternalStorageId"); + + b.ToTable("ProviderImages"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Images.Image", b => + { + b.Property("EntityId") + .HasColumnType("binary(16)"); + + b.Property("ExternalStorageId") + .HasColumnType("varchar(255)"); + + b.HasKey("EntityId", "ExternalStorageId"); + + b.ToTable("WorkshopImages"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.InstitutionAdmin", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("InstitutionId") + .HasColumnType("binary(16)"); + + b.Property("UserId") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("InstitutionId"); + + b.ToTable("InstitutionAdmins"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.InstitutionStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.ToTable("InstitutionStatuses"); + + b.HasData( + new + { + Id = 1L, + Name = "Працює" + }, + new + { + Id = 2L, + Name = "Перебуває в стані реорганізації" + }, + new + { + Id = 3L, + Name = "Має намір на реорганізацію" + }, + new + { + Id = 4L, + Name = "Відсутній" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.Property("GroupedData") + .HasColumnType("longtext"); + + b.Property("ObjectId") + .HasColumnType("binary(16)"); + + b.Property("ReadDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Parent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Parents"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.PermissionsForRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("PackedPermissions") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.HasKey("Id"); + + b.ToTable("PermissionsForRoles"); + + b.HasData( + new + { + Id = 1L, + Description = "admin permissions", + PackedPermissions = "de\n \r  !()+4325>== + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("ActualAddressId") + .HasColumnType("bigint"); + + b.Property("CoverImageId") + .HasColumnType("longtext"); + + b.Property("Director") + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("varchar(50)"); + + b.Property("DirectorDateOfBirth") + .HasColumnType("Date"); + + b.Property("EdrpouIpn") + .HasMaxLength(12) + .HasColumnType("bigint"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Facebook") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Founder") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("FullTitle") + .IsRequired() + .HasMaxLength(60) + .IsUnicode(true) + .HasColumnType("varchar(60)"); + + b.Property("Instagram") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("InstitutionId") + .HasColumnType("binary(16)"); + + b.Property("InstitutionStatusId") + .HasColumnType("bigint"); + + b.Property("InstitutionType") + .HasColumnType("int"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("LegalAddressId") + .HasColumnType("bigint"); + + b.Property("License") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("LicenseStatus") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Ownership") + .HasColumnType("int"); + + b.Property("PhoneNumber") + .HasMaxLength(15) + .HasColumnType("varchar(15)"); + + b.Property("ShortTitle") + .IsRequired() + .HasMaxLength(60) + .IsUnicode(true) + .HasColumnType("varchar(60)"); + + b.Property("Status") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("Website") + .HasMaxLength(256) + .IsUnicode(true) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("ActualAddressId"); + + b.HasIndex("InstitutionId"); + + b.HasIndex("InstitutionStatusId"); + + b.HasIndex("LegalAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("Providers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderAdmin", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("IsDeputy") + .HasColumnType("tinyint(1)"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.HasKey("UserId"); + + b.HasIndex("ProviderId"); + + b.ToTable("ProviderAdmins"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderAdminChangesLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ManagedWorkshopId") + .HasColumnType("binary(16)"); + + b.Property("OperationDate") + .HasColumnType("datetime(6)"); + + b.Property("OperationType") + .HasColumnType("int"); + + b.Property("ProviderAdminUserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("ManagedWorkshopId"); + + b.HasIndex("ProviderAdminUserId"); + + b.HasIndex("ProviderId"); + + b.HasIndex("UserId"); + + b.ToTable("ProviderAdminChangesLog"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderSectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("ProviderId"); + + b.ToTable("ProviderSectionItems"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Rating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("EntityId") + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("Rate") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("Ratings"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SocialGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.ToTable("SocialGroups"); + + b.HasData( + new + { + Id = 1L, + Name = "Діти із багатодітних сімей" + }, + new + { + Id = 2L, + Name = "Діти із малозабезпечених сімей" + }, + new + { + Id = 3L, + Name = "Діти з інвалідністю" + }, + new + { + Id = 4L, + Name = "Діти-сироти" + }, + new + { + Id = 5L, + Name = "Діти, позбавлені батьківського піклування" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SubordinationStructure.Institution", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("NumberOfHierarchyLevels") + .HasColumnType("int"); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Institutions"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SubordinationStructure.InstitutionFieldDescription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("HierarchyLevel") + .HasColumnType("int"); + + b.Property("InstitutionId") + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("InstitutionId"); + + b.ToTable("InstitutionFieldDescriptions"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SubordinationStructure.InstitutionHierarchy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("HierarchyLevel") + .HasColumnType("int"); + + b.Property("InstitutionId") + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("InstitutionId"); + + b.HasIndex("ParentId"); + + b.ToTable("InstitutionHierarchies"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Teacher", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("CoverImageId") + .HasColumnType("longtext"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("MiddleName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("WorkshopId"); + + b.ToTable("Teachers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.User", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("CreatingTime") + .HasColumnType("datetime(6)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("IsBlocked") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("IsDerived") + .HasColumnType("tinyint(1)"); + + b.Property("IsRegistered") + .HasColumnType("tinyint(1)"); + + b.Property("LastLogin") + .HasColumnType("datetime(6)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("MiddleName") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasMaxLength(84) + .IsUnicode(false) + .HasColumnType("char(84)") + .IsFixedLength(); + + b.Property("PhoneNumber") + .HasMaxLength(15) + .IsUnicode(false) + .HasColumnType("varchar(15)") + .IsFixedLength(false); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("Role") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(36) + .IsUnicode(false) + .HasColumnType("varchar(36)") + .IsFixedLength(false); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AddressId") + .HasColumnType("bigint"); + + b.Property("AvailableSeats") + .HasColumnType("int unsigned"); + + b.Property("ClassId") + .HasColumnType("bigint"); + + b.Property("CoverImageId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DepartmentId") + .HasColumnType("bigint"); + + b.Property("DirectionId") + .HasColumnType("bigint"); + + b.Property("DisabilityOptionsDesc") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Facebook") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Instagram") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("InstitutionHierarchyId") + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("Keywords") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("MaxAge") + .HasColumnType("int"); + + b.Property("MinAge") + .HasColumnType("int"); + + b.Property("PayRate") + .HasColumnType("int"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("varchar(15)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.Property("ProviderOwnership") + .HasColumnType("int"); + + b.Property("ProviderTitle") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("Website") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("WithDisabilityOptions") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("ClassId"); + + b.HasIndex("DirectionId"); + + b.HasIndex("InstitutionHierarchyId"); + + b.HasIndex("ProviderId"); + + b.ToTable("Workshops"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.WorkshopDescriptionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)"); + + b.Property("SectionName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("WorkshopId"); + + b.ToTable("WorkshopDescriptionItems"); + }); + + modelBuilder.Entity("ProviderAdminWorkshop", b => + { + b.Property("ManagedWorkshopsId") + .HasColumnType("binary(16)"); + + b.Property("ProviderAdminsUserId") + .HasColumnType("varchar(255)"); + + b.HasKey("ManagedWorkshopsId", "ProviderAdminsUserId"); + + b.HasIndex("ProviderAdminsUserId"); + + b.ToTable("ProviderAdminWorkshop"); + }); + + modelBuilder.Entity("AchievementChild", b => + { + b.HasOne("OutOfSchool.Services.Models.Achievement", null) + .WithMany() + .HasForeignKey("AchievementsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Child", null) + .WithMany() + .HasForeignKey("ChildrenId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("DirectionInstitutionHierarchy", b => + { + b.HasOne("OutOfSchool.Services.Models.Direction", null) + .WithMany() + .HasForeignKey("DirectionsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.InstitutionHierarchy", null) + .WithMany() + .HasForeignKey("InstitutionHierarchiesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("OutOfSchool.Services.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("OutOfSchool.Services.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("OutOfSchool.Services.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Achievement", b => + { + b.HasOne("OutOfSchool.Services.Models.AchievementType", "AchievementType") + .WithMany() + .HasForeignKey("AchievementTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Workshop", "Workshop") + .WithMany() + .HasForeignKey("WorkshopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AchievementType"); + + b.Navigation("Workshop"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AchievementTeacher", b => + { + b.HasOne("OutOfSchool.Services.Models.Achievement", "Achievement") + .WithMany("Teachers") + .HasForeignKey("AchievementId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Achievement"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Address", b => + { + b.HasOne("OutOfSchool.Services.Models.Codeficator", "Codeficator") + .WithMany() + .HasForeignKey("CodeficatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Codeficator"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Application", b => + { + b.HasOne("OutOfSchool.Services.Models.Child", "Child") + .WithMany() + .HasForeignKey("ChildId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Parent", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Workshop", "Workshop") + .WithMany("Applications") + .HasForeignKey("WorkshopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Child"); + + b.Navigation("Parent"); + + b.Navigation("Workshop"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.BlockedProviderParent", b => + { + b.HasOne("OutOfSchool.Services.Models.Parent", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") + .WithMany() + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChangesLog", b => + { + b.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatMessageWorkshop", b => + { + b.HasOne("OutOfSchool.Services.Models.ChatWorkshop.ChatRoomWorkshop", "ChatRoom") + .WithMany("ChatMessages") + .HasForeignKey("ChatRoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChatRoom"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatRoomWorkshop", b => + { + b.HasOne("OutOfSchool.Services.Models.Parent", "Parent") + .WithMany("ChatRooms") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Workshop", "Workshop") + .WithMany("ChatRooms") + .HasForeignKey("WorkshopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + + b.Navigation("Workshop"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Child", b => + { + b.HasOne("OutOfSchool.Services.Models.Parent", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChildSocialGroup", b => + { + b.HasOne("OutOfSchool.Services.Models.Child", "Child") + .WithMany("ChildSocialGroups") + .HasForeignKey("ChildId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.SocialGroup", "SocialGroup") + .WithMany("ChildSocialGroups") + .HasForeignKey("SocialGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Child"); + + b.Navigation("SocialGroup"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Class", b => + { + b.HasOne("OutOfSchool.Services.Models.Department", "Department") + .WithMany("Classes") + .HasForeignKey("DepartmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Department"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Codeficator", b => + { + b.HasOne("OutOfSchool.Services.Models.Codeficator", "Parent") + .WithMany("Childs") + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.CompanyInformationItem", b => + { + b.HasOne("OutOfSchool.Services.Models.CompanyInformation", "CompanyInformation") + .WithMany("CompanyInformationItems") + .HasForeignKey("CompanyInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyInformation"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.DateTimeRange", b => + { + b.HasOne("OutOfSchool.Services.Models.Workshop", null) + .WithMany("DateTimeRanges") + .HasForeignKey("WorkshopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Department", b => + { + b.HasOne("OutOfSchool.Services.Models.Direction", "Direction") + .WithMany("Departments") + .HasForeignKey("DirectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Direction"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Favorite", b => + { + b.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Workshop", "Workshop") + .WithMany() + .HasForeignKey("WorkshopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + + b.Navigation("Workshop"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Images.Image", b => + { + b.HasOne("OutOfSchool.Services.Models.Provider", "Entity") + .WithMany("Images") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Entity"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Images.Image", b => + { + b.HasOne("OutOfSchool.Services.Models.Workshop", "Entity") + .WithMany("Images") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Entity"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.InstitutionAdmin", b => + { + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.Institution", "Institution") + .WithMany() + .HasForeignKey("InstitutionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Institution"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Parent", b => + { + b.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Provider", b => + { + b.HasOne("OutOfSchool.Services.Models.Address", "ActualAddress") + .WithMany() + .HasForeignKey("ActualAddressId"); + + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.Institution", "Institution") + .WithMany() + .HasForeignKey("InstitutionId"); + + b.HasOne("OutOfSchool.Services.Models.InstitutionStatus", "InstitutionStatus") + .WithMany("Providers") + .HasForeignKey("InstitutionStatusId"); + + b.HasOne("OutOfSchool.Services.Models.Address", "LegalAddress") + .WithMany() + .HasForeignKey("LegalAddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ActualAddress"); + + b.Navigation("Institution"); + + b.Navigation("InstitutionStatus"); + + b.Navigation("LegalAddress"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderAdmin", b => + { + b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") + .WithMany("ProviderAdmins") + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderAdminChangesLog", b => + { + b.HasOne("OutOfSchool.Services.Models.Workshop", "ManagedWorkshop") + .WithMany() + .HasForeignKey("ManagedWorkshopId"); + + b.HasOne("OutOfSchool.Services.Models.User", "ProviderAdminUser") + .WithMany() + .HasForeignKey("ProviderAdminUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") + .WithMany() + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ManagedWorkshop"); + + b.Navigation("Provider"); + + b.Navigation("ProviderAdminUser"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderSectionItem", b => + { + b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") + .WithMany("ProviderSectionItems") + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Rating", b => + { + b.HasOne("OutOfSchool.Services.Models.Parent", "Parent") + .WithMany() + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SubordinationStructure.InstitutionFieldDescription", b => + { + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.Institution", "Institution") + .WithMany() + .HasForeignKey("InstitutionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Institution"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SubordinationStructure.InstitutionHierarchy", b => + { + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.Institution", "Institution") + .WithMany() + .HasForeignKey("InstitutionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.InstitutionHierarchy", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Institution"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Teacher", b => + { + b.HasOne("OutOfSchool.Services.Models.Workshop", "Workshop") + .WithMany("Teachers") + .HasForeignKey("WorkshopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Workshop"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => + { + b.HasOne("OutOfSchool.Services.Models.Address", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Class", "Class") + .WithMany() + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Direction", "Direction") + .WithMany() + .HasForeignKey("DirectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.InstitutionHierarchy", "InstitutionHierarchy") + .WithMany() + .HasForeignKey("InstitutionHierarchyId"); + + b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") + .WithMany("Workshops") + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Address"); + + b.Navigation("Class"); + + b.Navigation("Direction"); + + b.Navigation("InstitutionHierarchy"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.WorkshopDescriptionItem", b => + { + b.HasOne("OutOfSchool.Services.Models.Workshop", "Workshop") + .WithMany("WorkshopDescriptionItems") + .HasForeignKey("WorkshopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Workshop"); + }); + + modelBuilder.Entity("ProviderAdminWorkshop", b => + { + b.HasOne("OutOfSchool.Services.Models.Workshop", null) + .WithMany() + .HasForeignKey("ManagedWorkshopsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.ProviderAdmin", null) + .WithMany() + .HasForeignKey("ProviderAdminsUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Achievement", b => + { + b.Navigation("Teachers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatRoomWorkshop", b => + { + b.Navigation("ChatMessages"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Child", b => + { + b.Navigation("ChildSocialGroups"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Codeficator", b => + { + b.Navigation("Childs"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.CompanyInformation", b => + { + b.Navigation("CompanyInformationItems"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Department", b => + { + b.Navigation("Classes"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Direction", b => + { + b.Navigation("Departments"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.InstitutionStatus", b => + { + b.Navigation("Providers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Parent", b => + { + b.Navigation("ChatRooms"); + + b.Navigation("Children"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Provider", b => + { + b.Navigation("Images"); + + b.Navigation("ProviderAdmins"); + + b.Navigation("ProviderSectionItems"); + + b.Navigation("Workshops"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SocialGroup", b => + { + b.Navigation("ChildSocialGroups"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => + { + b.Navigation("Applications"); + + b.Navigation("ChatRooms"); + + b.Navigation("DateTimeRanges"); + + b.Navigation("Images"); + + b.Navigation("Teachers"); + + b.Navigation("WorkshopDescriptionItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220720094332_AddressAddCodeficatorId.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220720094332_AddressAddCodeficatorId.cs new file mode 100644 index 0000000000..f81f441fcc --- /dev/null +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220720094332_AddressAddCodeficatorId.cs @@ -0,0 +1,46 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations; + +public partial class AddressAddCodeficatorId : Migration +{ + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CodeficatorId", + table: "Addresses", + type: "bigint", + nullable: false, + defaultValue: 4970L); + + migrationBuilder.CreateIndex( + name: "IX_Addresses_CodeficatorId", + table: "Addresses", + column: "CodeficatorId"); + + migrationBuilder.AddForeignKey( + name: "FK_Addresses_Codeficators_CodeficatorId", + table: "Addresses", + column: "CodeficatorId", + principalTable: "Codeficators", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Addresses_Codeficators_CodeficatorId", + table: "Addresses"); + + migrationBuilder.DropIndex( + name: "IX_Addresses_CodeficatorId", + table: "Addresses"); + + migrationBuilder.DropColumn( + name: "CodeficatorId", + table: "Addresses"); + } +} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs index f7f745935e..3266c8b18b 100644 --- a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs @@ -325,6 +325,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(30) .HasColumnType("varchar(30)"); + b.Property("CodeficatorId") + .HasColumnType("bigint"); + b.Property("District") .HasMaxLength(30) .HasColumnType("varchar(30)"); @@ -350,6 +353,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.HasIndex("CodeficatorId"); + b.ToTable("Addresses"); }); @@ -1903,6 +1908,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Achievement"); }); + modelBuilder.Entity("OutOfSchool.Services.Models.Address", b => + { + b.HasOne("OutOfSchool.Services.Models.Codeficator", "Codeficator") + .WithMany() + .HasForeignKey("CodeficatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Codeficator"); + }); + modelBuilder.Entity("OutOfSchool.Services.Models.Application", b => { b.HasOne("OutOfSchool.Services.Models.Child", "Child") diff --git a/OutOfSchool/OutOfSchool.WebApi.Tests/Services/AddressServiceTests.cs b/OutOfSchool/OutOfSchool.WebApi.Tests/Services/AddressServiceTests.cs index 2ffd24c2db..8cc10bb128 100644 --- a/OutOfSchool/OutOfSchool.WebApi.Tests/Services/AddressServiceTests.cs +++ b/OutOfSchool/OutOfSchool.WebApi.Tests/Services/AddressServiceTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using AutoMapper; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; @@ -25,6 +26,7 @@ public class AddressServiceTests private IAddressService service; private Mock> localizer; private Mock> logger; + private IMapper mapper; [SetUp] public void SetUp() @@ -38,7 +40,10 @@ public void SetUp() localizer = new Mock>(); repo = new EntityRepository(context); logger = new Mock>(); - service = new AddressService(repo, logger.Object, localizer.Object); + var config = new MapperConfiguration(cfg => cfg.AddProfile()); + mapper = config.CreateMapper(); + + service = new AddressService(repo, logger.Object, localizer.Object, mapper); SeedDatabase(); } @@ -57,10 +62,11 @@ public async Task Create_WhenEntityIsValid_ReturnsCreatedEntity() BuildingNumber = "NewBuildingNumber", Latitude = 60.45383, Longitude = 70.56765, + CodeficatorId = 1, }; // Act - var result = await service.Create(expected.ToModel()).ConfigureAwait(false); + var result = await service.Create(mapper.Map(expected)).ConfigureAwait(false); // Assert Assert.AreEqual(expected.Region, result.Region); @@ -180,65 +186,93 @@ private void SeedDatabase() context.Database.EnsureCreated(); var addresses = new List
() - { - new Address() - { - Id = 1, - Region = "Region1", - District = "District1", - City = "City1", - Street = "Street1", - BuildingNumber = "BuildingNumber1", - Latitude = 41.45383, - Longitude = 51.56765, - }, - new Address() - { - Id = 2, - Region = "Region2", - District = "District2", - City = "City2", - Street = "Street2", - BuildingNumber = "BuildingNumber2", - Latitude = 42.45383, - Longitude = 52.56765, - }, - new Address() - { - Id = 3, - Region = "Region3", - District = "District3", - City = "City3", - Street = "Street3", - BuildingNumber = "BuildingNumber3", - Latitude = 43.45383, - Longitude = 53.56765, - }, - new Address() - { - Id = 4, - Region = "Region4", - District = "District4", - City = "City4", - Street = "Street4", - BuildingNumber = "BuildingNumber4", - Latitude = 44.45383, - Longitude = 54.56765, - }, - new Address() { - Id = 5, - Region = "Region5", - District = "District5", - City = "City5", - Street = "Street5", - BuildingNumber = "BuildingNumber5", - Latitude = 45.45383, - Longitude = 55.56765, - }, - }; + new Address() + { + Id = 1, + Region = "Region1", + District = "District1", + City = "City1", + Street = "Street1", + BuildingNumber = "BuildingNumber1", + Latitude = 41.45383, + Longitude = 51.56765, + CodeficatorId = 1, + }, + new Address() + { + Id = 2, + Region = "Region2", + District = "District2", + City = "City2", + Street = "Street2", + BuildingNumber = "BuildingNumber2", + Latitude = 42.45383, + Longitude = 52.56765, + CodeficatorId = 2, + }, + new Address() + { + Id = 3, + Region = "Region3", + District = "District3", + City = "City3", + Street = "Street3", + BuildingNumber = "BuildingNumber3", + Latitude = 43.45383, + Longitude = 53.56765, + CodeficatorId = 2, + }, + new Address() + { + Id = 4, + Region = "Region4", + District = "District4", + City = "City4", + Street = "Street4", + BuildingNumber = "BuildingNumber4", + Latitude = 44.45383, + Longitude = 54.56765, + CodeficatorId = 2, + }, + new Address() + { + Id = 5, + Region = "Region5", + District = "District5", + City = "City5", + Street = "Street5", + BuildingNumber = "BuildingNumber5", + Latitude = 45.45383, + Longitude = 55.56765, + CodeficatorId = 2, + }, + }; context.Addresses.AddRange(addresses); + + var codeficators = new List() + { + new Codeficator() + { + Id = 1, + Name = "Test", + Category = "О", + Latitude = 41.45383, + Longitude = 51.56765, + }, + new Codeficator() + { + Id = 2, + Name = "Test2", + Category = "О", + Latitude = 41.45383, + Longitude = 51.56765, + }, + }; + + context.Codeficators.AddRange(codeficators); + context.SaveChanges(); } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/AddressDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/AddressDto.cs index a4f8ee62b3..429574a526 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/AddressDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/AddressDto.cs @@ -1,5 +1,5 @@ -using System; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; +using OutOfSchool.WebApi.Models.Codeficator; namespace OutOfSchool.WebApi.Models; @@ -30,6 +30,10 @@ public class AddressDto public double Longitude { get; set; } + public long CodeficatorId { get; set; } + + public AllAddressPartsDto CodeficatorAddressDto { get; set; } + // Note: implementation taken from the OutOfSchool.Services.Models.Address public override int GetHashCode() { @@ -52,7 +56,7 @@ public override bool Equals(object obj) return false; } - if (!(obj is AddressDto address)) + if (obj is not AddressDto address) { return false; } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/AllAddressPartsDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/AllAddressPartsDto.cs index e78431c66f..f19e0274aa 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/AllAddressPartsDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/AllAddressPartsDto.cs @@ -1,21 +1,26 @@ -using OutOfSchool.Common; +using Newtonsoft.Json; +using OutOfSchool.Common.Models; +using OutOfSchool.Services.Enums; namespace OutOfSchool.WebApi.Models.Codeficator; -public class AllAddressPartsDto +public class AllAddressPartsDto : CodeficatorAddressDto { public string FullAddress { get { - return GetFullAddress(AddressParts, string.Empty); + return GetFullAddress(AddressParts, string.Empty, true); } } - public CodeficatorWithParentDto AddressParts { get; set; } + [JsonIgnore] + public CodeficatorDto AddressParts { get; set; } - private string GetFullAddress(CodeficatorWithParentDto codeficator, string address) + private string GetFullAddress(CodeficatorDto codeficator, string address, bool isEndPointAddressItem = false) { + FillAddressPart(codeficator, isEndPointAddressItem); + address += (address.Length == 0 ? string.Empty : Constants.AddressSeparator) + codeficator.Name; if (codeficator.Parent != null) @@ -25,4 +30,38 @@ private string GetFullAddress(CodeficatorWithParentDto codeficator, string addre return address; } + + private void FillAddressPart(CodeficatorDto codeficator, bool isEndPointAddressItem = false) + { + if (isEndPointAddressItem) + { + Category = codeficator.Category; + Latitude = codeficator.Latitude; + Longitude = codeficator.Longitude; + Id = codeficator.Id; + } + + var r2 = CodeficatorCategory.FromName(codeficator.Category); + switch (r2) + { + case var e when e.Equals(CodeficatorCategory.Region): + Region = $"{codeficator.Name} {CodeficatorCategory.Region.Abbrivation}"; + break; + case var e when e.Equals(CodeficatorCategory.District): + District = $"{codeficator.Name} {CodeficatorCategory.District.Abbrivation}"; + break; + case var e when e.Equals(CodeficatorCategory.TerritorialCommunity): + TerritorialCommunity = $"{codeficator.Name} {CodeficatorCategory.TerritorialCommunity.Abbrivation}"; + break; + case var e when e.Equals(CodeficatorCategory.City) + || e.Equals(CodeficatorCategory.UrbanSettlement) + || e.Equals(CodeficatorCategory.Village) + || e.Equals(CodeficatorCategory.Settlement): + Settlement = $"{CodeficatorCategory.FromValue(e).Abbrivation} {codeficator.Name}"; + break; + case var e when e.Equals(CodeficatorCategory.CityDistrict): + CityDistrict = $"{codeficator.Name} {CodeficatorCategory.CityDistrict.Abbrivation}"; + break; + } + } } \ No newline at end of file diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/CodeficatorDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/CodeficatorDto.cs index 452f5f9fde..39fe35088a 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/CodeficatorDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/CodeficatorDto.cs @@ -20,4 +20,6 @@ public class CodeficatorDto public double Latitude { get; set; } public double Longitude { get; set; } + + public CodeficatorDto Parent { get; set; } } \ No newline at end of file diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/CodeficatorWithParentDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/CodeficatorWithParentDto.cs deleted file mode 100644 index a04894cd55..0000000000 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Codeficator/CodeficatorWithParentDto.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace OutOfSchool.WebApi.Models.Codeficator; - -public class CodeficatorWithParentDto : CodeficatorDto -{ - public CodeficatorWithParentDto Parent { get; set; } -} \ No newline at end of file diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/AddressService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/AddressService.cs index ec36273c8f..cf0312a0c3 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/AddressService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/AddressService.cs @@ -1,14 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using AutoMapper; using Microsoft.Extensions.Localization; -using Microsoft.Extensions.Logging; -using OutOfSchool.Services.Models; -using OutOfSchool.Services.Repository; -using OutOfSchool.WebApi.Extensions; using OutOfSchool.WebApi.Models; namespace OutOfSchool.WebApi.Services; @@ -21,6 +12,7 @@ public class AddressService : IAddressService private readonly IEntityRepository repository; private readonly ILogger logger; private readonly IStringLocalizer localizer; + private readonly IMapper mapper; /// /// Initializes a new instance of the class. @@ -28,14 +20,17 @@ public class AddressService : IAddressService /// Repository. /// Logger. /// Localizer. + /// Mapper. public AddressService( IEntityRepository repository, ILogger logger, - IStringLocalizer localizer) + IStringLocalizer localizer, + IMapper mapper) { - this.localizer = localizer; - this.repository = repository; - this.logger = logger; + this.repository = repository ?? throw new ArgumentNullException(nameof(repository)); + this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); + this.localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); + this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); } /// @@ -43,7 +38,7 @@ public Task Create(AddressDto dto) { logger.LogInformation("Address creating was started."); - return CreateInternal(dto.ToDomain()); + return CreateInternal(mapper.Map
(dto)); } /// @@ -53,11 +48,11 @@ public async Task> GetAll() var addresses = await repository.GetAll().ConfigureAwait(false); - logger.LogInformation(!addresses.Any() - ? "Address table is empty." - : $"All {addresses.Count()} records were successfully received from the Address table"); + logger.LogInformation(addresses.Any() + ? $"All {addresses.Count()} records were successfully received from the Address table" + : "Address table is empty."); - return addresses.Select(address => address.ToModel()).ToList(); + return mapper.Map>(addresses); } /// @@ -76,7 +71,7 @@ public async Task GetById(long id) logger.LogInformation($"Successfully got an Address with Id = {id}."); - return address.ToModel(); + return mapper.Map(address); } /// @@ -86,11 +81,11 @@ public async Task Update(AddressDto dto) try { - var address = await repository.Update(dto.ToDomain()).ConfigureAwait(false); + var address = await repository.Update(mapper.Map
(dto)).ConfigureAwait(false); logger.LogInformation($"Address with Id = {address?.Id} updated succesfully."); - return address.ToModel(); + return mapper.Map(address); } catch (DbUpdateConcurrencyException) { @@ -125,6 +120,6 @@ private async Task CreateInternal(Address address) logger.LogInformation($"Address with Id = {newAddress?.Id} created successfully."); - return newAddress.ToModel(); + return mapper.Map(newAddress); } } \ No newline at end of file diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/CodeficatorService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/CodeficatorService.cs index da7091c4ea..50a70874fe 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/CodeficatorService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/CodeficatorService.cs @@ -55,7 +55,7 @@ public async Task GetAllAddressPartsById(long id) return null; } - return new AllAddressPartsDto { AddressParts = mapper.Map(codeficator) }; + return new AllAddressPartsDto { AddressParts = mapper.Map(codeficator) }; } /// diff --git a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs index ccdaab6051..8781c8497a 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs @@ -7,6 +7,7 @@ using GrpcService; using OutOfSchool.Common.Models; using OutOfSchool.ElasticsearchData.Models; +using OutOfSchool.Services.Enums; using OutOfSchool.Services.Models; using OutOfSchool.Services.Models.SubordinationStructure; using OutOfSchool.WebApi.Models; @@ -87,7 +88,13 @@ public MappingProfile() CreateMap().ReverseMap(); - CreateMap().ReverseMap(); + CreateMap() + .ForPath( + dest => dest.CodeficatorAddressDto.AddressParts, + opt => opt.MapFrom(src => src.Codeficator)); + + CreateMap() + .ForMember(dest => dest.Codeficator, opt => opt.Ignore()); CreateMap() .ForMember(dest => dest.Id, opt => opt.Ignore()) @@ -192,7 +199,6 @@ public MappingProfile() CreateMap().ReverseMap(); CreateMap(); - CreateMap(); CreateMap().ReverseMap() .ForMember(n => n.Id, n => n.Ignore());