diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/AverageRating.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/AverageRating.cs index 117ac3166c..e9fd07870c 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/AverageRating.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/AverageRating.cs @@ -1,17 +1,14 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using OutOfSchool.Services.Enums; namespace OutOfSchool.Services.Models; -public class AverageRating : IKeyedEntity +public class AverageRating : IKeyedEntity, ISoftDeleted { public long Id { get; set; } + public bool IsDeleted { get; set; } + public float Rate { get; set; } public int RateQuantity { get; set; } diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/AverageRatingConfiguration.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/AverageRatingConfiguration.cs index a7ad92f08a..2d18122971 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/AverageRatingConfiguration.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/AverageRatingConfiguration.cs @@ -9,5 +9,9 @@ internal class AverageRatingConfiguration : IEntityTypeConfiguration builder) { builder.HasIndex(x => x.EntityId); + + builder.HasIndex(x => x.IsDeleted); + + builder.Property(x => x.IsDeleted).HasDefaultValue(false); } } diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/QuartzJobConfiguration.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/QuartzJobConfiguration.cs new file mode 100644 index 0000000000..7152563064 --- /dev/null +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/QuartzJobConfiguration.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace OutOfSchool.Services.Models.Configurations; + +internal class QuartzJobConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(x => x.Id); + } +} diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/RatingConfiguration.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/RatingConfiguration.cs index cec9f0abd6..a4623760bd 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/RatingConfiguration.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/Configurations/RatingConfiguration.cs @@ -1,5 +1,4 @@ - -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace OutOfSchool.Services.Models.Configurations; @@ -9,5 +8,9 @@ internal class RatingConfiguration : IEntityTypeConfiguration public void Configure(EntityTypeBuilder builder) { builder.HasIndex(x => x.EntityId); + + builder.HasIndex(x => x.IsDeleted); + + builder.Property(x => x.IsDeleted).HasDefaultValue(false); } } diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/IDto.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/IDto.cs new file mode 100644 index 0000000000..cca2907b35 --- /dev/null +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/IDto.cs @@ -0,0 +1,7 @@ +namespace OutOfSchool.Services.Models; + +public interface IDto + where TEntity : IKeyedEntity +{ + TKey Id { get; set; } +} diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/IKeyedEntity.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/IKeyedEntity.cs index bbe62bec06..2b29f70058 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/IKeyedEntity.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/IKeyedEntity.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OutOfSchool.Services.Models; +namespace OutOfSchool.Services.Models; public interface IKeyedEntity : IKeyedEntity { diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/QuartzJob.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/QuartzJob.cs index 6f4dcc5370..d281e53fb2 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/QuartzJob.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/QuartzJob.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace OutOfSchool.Services.Models; + public class QuartzJob : IKeyedEntity { public long Id { get; set; } diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/Rating.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/Rating.cs index 85091514cd..7a2031dde9 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/Rating.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/Rating.cs @@ -1,14 +1,14 @@ using System; using System.ComponentModel.DataAnnotations; -using OutOfSchool.Services.Enums; - namespace OutOfSchool.Services.Models; -public class Rating : IKeyedEntity +public class Rating : IKeyedEntity, ISoftDeleted { public long Id { get; set; } + public bool IsDeleted { get; set; } + [Range(1, 5)] public int Rate { get; set; } diff --git a/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.SoftDelete.cs b/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.SoftDelete.cs index 6a80f34f57..cb0b6462bb 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.SoftDelete.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.SoftDelete.cs @@ -46,7 +46,6 @@ private void ApplySoftDelete(ModelBuilder builder) .ApplySoftDelete() .ApplySoftDelete
() .ApplySoftDelete() - .ApplySoftDelete() .ApplySoftDelete() .ApplySoftDelete() .ApplySoftDelete() @@ -59,11 +58,9 @@ private void ApplySoftDelete(ModelBuilder builder) .ApplySoftDelete() .ApplySoftDelete() .ApplySoftDelete() - .ApplySoftDelete() .ApplySoftDelete() .ApplySoftDelete() .ApplySoftDelete() - .ApplySoftDelete() - .ApplySoftDelete(); + .ApplySoftDelete(); } } diff --git a/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.cs b/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.cs index 53c4f9c09c..be5482c8a5 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.cs @@ -144,6 +144,7 @@ protected override void OnModelCreating(ModelBuilder builder) builder.ApplyConfiguration(new OperationWithObjectConfiguration()); builder.ApplyConfiguration(new ProviderConfiguration()); builder.ApplyConfiguration(new ProviderAdminConfiguration()); + builder.ApplyConfiguration(new QuartzJobConfiguration()); builder.ApplyConfiguration(new RatingConfiguration()); builder.ApplyConfiguration(new TeacherConfiguration()); builder.ApplyConfiguration(new WorkshopConfiguration()); diff --git a/OutOfSchool/OutOfSchool.DataAccess/Repository/EntityRepositoryBase.cs b/OutOfSchool/OutOfSchool.DataAccess/Repository/EntityRepositoryBase.cs index 1cb7cd127b..b72ba810ef 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Repository/EntityRepositoryBase.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Repository/EntityRepositoryBase.cs @@ -171,6 +171,22 @@ public virtual async Task Update(TEntity entity) return entity; } + public async Task ReadAndUpdateWith(TDto dto, Func map) + where TDto : IDto + { + ArgumentNullException.ThrowIfNull(dto); + + var entity = await GetById(dto.Id).ConfigureAwait(false); + + if (entity is null) + { + var name = typeof(TEntity).Name; + throw new DbUpdateConcurrencyException($"Updating failed. {name} with Id = {dto.Id} doesn't exist in the system."); + } + + return await Update(map(dto, entity)).ConfigureAwait(false); + } + /// public virtual Task Count(Expression> whereExpression = null) { diff --git a/OutOfSchool/OutOfSchool.DataAccess/Repository/IEntityRepository.cs b/OutOfSchool/OutOfSchool.DataAccess/Repository/IEntityRepository.cs index e4ea47c402..1855dd071e 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Repository/IEntityRepository.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Repository/IEntityRepository.cs @@ -50,6 +50,18 @@ public interface IEntityRepositoryBase /// A representing the result of the asynchronous operation. Task RunInTransaction(Func operation); + /// + /// Read element from database by id and update information. + /// + /// New data with information. + /// Method that represents mapping operation. + /// A representing the result of the asynchronous operation. + /// The task result contains the entity that was updated. + /// An exception that is thrown when an error is encountered while saving to the database. + /// If a concurrency violation is encountered while saving to database. + Task ReadAndUpdateWith(TDto dto, Func map) + where TDto : IDto; + /// /// Update information about element. /// diff --git a/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/20230925195746_RemoveSoftDeleteQuartzJob.Designer.cs b/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/20230925195746_RemoveSoftDeleteQuartzJob.Designer.cs new file mode 100644 index 0000000000..1936f9c8de --- /dev/null +++ b/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/20230925195746_RemoveSoftDeleteQuartzJob.Designer.cs @@ -0,0 +1,2898 @@ +// +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.Migrations.Data.Migrations.OutOfSchoolMigrations +{ + [DbContext(typeof(OutOfSchoolDbContext))] + [Migration("20230925195746_RemoveSoftDeleteQuartzJob")] + partial class RemoveSoftDeleteQuartzJob + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.16") + .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("ChildSocialGroup", b => + { + b.Property("ChildrenId") + .HasColumnType("binary(16)"); + + b.Property("SocialGroupsId") + .HasColumnType("bigint"); + + b.HasKey("ChildrenId", "SocialGroupsId"); + + b.HasIndex("SocialGroupsId"); + + b.ToTable("ChildSocialGroup"); + }); + + 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)") + .HasDefaultValue(false); + + b.Property("Title") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("AchievementTypeId"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("AchievementId"); + + b.HasIndex("IsDeleted"); + + b.ToTable("AchievementTeachers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AchievementType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("TitleEn") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.ToTable("AchievementTypes"); + + b.HasData( + new + { + Id = 1L, + IsDeleted = false, + Title = "Переможці міжнародних та всеукраїнських спортивних змагань (індивідуальних та командних)", + TitleEn = "Winners of international and all-Ukrainian sports competitions (individual and team)" + }, + new + { + Id = 2L, + IsDeleted = false, + Title = "Призери та учасники міжнародних, всеукраїнських та призери регіональних конкурсів і виставок наукових, технічних, дослідницьких, інноваційних, ІТ проектів", + TitleEn = "Winners and participants of international, all-Ukrainian and regional contests and exhibitions of scientific, technical, research, innovation, IT projects" + }, + new + { + Id = 3L, + IsDeleted = false, + Title = "Реципієнти міжнародних грантів", + TitleEn = "Recipients of international grants" + }, + new + { + Id = 4L, + IsDeleted = false, + Title = "Призери міжнародних культурних конкурсів та фестивалів", + TitleEn = "Winners of international cultural competitions and festivals" + }, + new + { + Id = 5L, + IsDeleted = false, + Title = "Соціально активні категорії учнів", + TitleEn = "Socially active categories of students" + }, + new + { + Id = 6L, + IsDeleted = false, + Title = "Цифрові інструменти Google для закладів вищої та фахової передвищої освіти", + TitleEn = "Google digital tools for institutions of higher and professional pre-higher education" + }, + new + { + Id = 7L, + IsDeleted = false, + Title = "Переможці та учасники олімпіад міжнародного та всеукраїнського рівнів", + TitleEn = "Winners and participants of olympiads at the international and all-Ukrainian levels" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("BuildingNumber") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("varchar(15)"); + + b.Property("CATOTTGId") + .HasColumnType("bigint"); + + b.Property("GeoHash") + .HasColumnType("bigint unsigned"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("Street") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.HasKey("Id"); + + b.HasIndex("CATOTTGId"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + 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("IsDeleted"); + + b.HasIndex("ParentId"); + + b.HasIndex("WorkshopId"); + + b.ToTable("Applications"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AreaAdmin", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("CATOTTGId") + .HasColumnType("bigint"); + + b.Property("InstitutionId") + .HasColumnType("binary(16)"); + + b.HasKey("UserId"); + + b.HasIndex("CATOTTGId"); + + b.HasIndex("InstitutionId"); + + b.ToTable("AreaAdmins"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AverageRating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("EntityId") + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("Rate") + .HasColumnType("float"); + + b.Property("RateQuantity") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EntityId"); + + b.HasIndex("IsDeleted"); + + b.ToTable("AverageRatings"); + }); + + 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)") + .HasDefaultValue(false); + + 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("IsDeleted"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProviderId"); + + b.ToTable("BlockedProviderParents"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.CATOTTG", 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)") + .HasDefaultValue(false); + + b.Property("IsTop") + .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("Order") + .HasColumnType("int"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ParentId"); + + b.ToTable("CATOTTGs"); + }); + + 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)") + .HasDefaultValue(false); + + b.Property("ReadDateTime") + .HasColumnType("datetime(6)"); + + b.Property("SenderRoleIsProvider") + .HasColumnType("tinyint(1)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("ChatRoomId"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + 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") + .IsRequired() + .HasColumnType("date"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("Gender") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("IsParent") + .HasColumnType("tinyint(1)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("MiddleName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("PlaceOfStudy") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ParentId"); + + b.ToTable("Children"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.CompanyInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("SectionName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CompanyInformationId"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("StartTime") + .HasColumnType("time(6)"); + + b.Property("Workdays") + .HasColumnType("tinyint unsigned"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("WorkshopId"); + + b.ToTable("DateTimeRanges"); + + b.HasCheckConstraint("CK_DateTimeRanges_EndTimeIsAfterStartTime", "EndTime >= StartTime"); + }); + + 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)") + .HasDefaultValue(false); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("UserId"); + + b.HasIndex("WorkshopId"); + + b.ToTable("Favorites"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.FileInDb", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("ContentType") + .HasColumnType("longtext"); + + b.Property("Data") + .HasColumnType("longblob"); + + b.HasKey("Id"); + + b.ToTable("FilesInDb"); + }); + + 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("UserId") + .HasColumnType("varchar(255)"); + + b.Property("InstitutionId") + .HasColumnType("binary(16)"); + + b.HasKey("UserId"); + + 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)") + .HasDefaultValue(false); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.ToTable("InstitutionStatuses"); + + b.HasData( + new + { + Id = 1L, + IsDeleted = false, + Name = "Працює" + }, + new + { + Id = 2L, + IsDeleted = false, + Name = "Перебуває в стані реорганізації" + }, + new + { + Id = 3L, + IsDeleted = false, + Name = "Має намір на реорганізацію" + }, + new + { + Id = 4L, + IsDeleted = false, + 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("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.OperationWithObject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Comment") + .HasColumnType("longtext"); + + b.Property("EntityId") + .HasColumnType("binary(16)"); + + b.Property("EntityType") + .HasColumnType("int"); + + b.Property("EventDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperationType") + .HasColumnType("int"); + + b.Property("RowSeparator") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("EntityId"); + + b.HasIndex("EntityType"); + + b.HasIndex("OperationType"); + + b.HasIndex("RowSeparator"); + + b.ToTable("OperationsWithObjects"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Parent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("DateOfBirth") + .IsRequired() + .HasColumnType("date"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + 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 = "techadmin permissions", + PackedPermissions = "def\n \r  !()+432578>== + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("ActualAddressId") + .HasColumnType("bigint"); + + b.Property("BlockPhoneNumber") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("varchar(15)"); + + b.Property("BlockReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("CoverImageId") + .HasColumnType("longtext"); + + b.Property("Director") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("varchar(50)"); + + b.Property("DirectorDateOfBirth") + .IsRequired() + .HasColumnType("Date"); + + b.Property("EdrpouIpn") + .IsRequired() + .HasMaxLength(12) + .HasColumnType("varchar(12)"); + + 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("IsBlocked") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + 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") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("varchar(15)"); + + b.Property("ShortTitle") + .IsRequired() + .HasMaxLength(60) + .IsUnicode(true) + .HasColumnType("varchar(60)"); + + b.Property("Status") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(10); + + b.Property("StatusReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("TypeId") + .HasColumnType("bigint"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("Website") + .HasMaxLength(256) + .IsUnicode(true) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("ActualAddressId") + .IsUnique(); + + b.HasIndex("EdrpouIpn"); + + b.HasIndex("InstitutionId"); + + b.HasIndex("InstitutionStatusId"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("LegalAddressId") + .IsUnique(); + + b.HasIndex("TypeId"); + + b.HasIndex("UserId"); + + b.ToTable("Providers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderAdmin", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("BlockingType") + .HasColumnType("int"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("IsDeputy") + .HasColumnType("tinyint(1)"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.HasKey("UserId"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ProviderId"); + + b.ToTable("ProviderSectionItems"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ProviderType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Name") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.HasKey("Id"); + + b.ToTable("ProviderTypes"); + + b.HasData( + new + { + Id = 1L, + Name = "Дитячо-юнацькі спортивні школи: комплексні дитячо-юнацькі спортивні школи, дитячо-юнацькі спортивні школи з видів спорту, дитячо-юнацькі спортивні школи для осіб з інвалідністю, спеціалізовані дитячо-юнацькі школи олімпійського резерву, спеціалізовані дитячо-юнацькі спортивні школи для осіб з інвалідністю паралімпійського та дефлімпійського резерву" + }, + new + { + Id = 2L, + Name = "Клуби: військово-патріотичного виховання, дитячо-юнацькі (моряків, річковиків, авіаторів, космонавтів, парашутистів, десантників, прикордонників, радистів, пожежників, автолюбителів, краєзнавців, туристів, етнографів, фольклористів, фізичної підготовки та інших напрямів)" + }, + new + { + Id = 3L, + Name = "Мала академія мистецтв (народних ремесел)" + }, + new + { + Id = 4L, + Name = "Мала академія наук учнівської молоді" + }, + new + { + Id = 5L, + Name = "Оздоровчі заклади для дітей та молоді: дитячо-юнацькі табори (містечка, комплекси): оздоровчі, заміські, профільні, праці та відпочинку, санаторного типу, з денним перебуванням; туристські бази" + }, + new + { + Id = 6L, + Name = "Мистецькі школи: музична, художня, хореографічна, хорова, школа мистецтв тощо" + }, + new + { + Id = 7L, + Name = "Центр, палац, будинок, клуб художньої творчості дітей, юнацтва та молоді, художньо-естетичної творчості учнівської молоді, дитячої та юнацької творчості, естетичного виховання" + }, + new + { + Id = 8L, + Name = "Центр, будинок, клуб еколого-натуралістичної творчості учнівської молоді, станція юних натуралістів" + }, + new + { + Id = 9L, + Name = "Центр, будинок, клуб науково-технічної творчості учнівської молоді, станція юних техніків" + }, + new + { + Id = 10L, + Name = "Центр, будинок, клуб, бюро туризму, краєзнавства, спорту та екскурсій учнівської молоді, туристсько-краєзнавчої творчості учнівської молоді, станція юних туристів" + }, + new + { + Id = 11L, + Name = "Центри: військово-патріотичного та інших напрямів позашкільної освіти" + }, + new + { + Id = 12L, + Name = "Дитяча бібліотека, дитяча флотилія моряків і річковиків, дитячий парк, дитячий стадіон, дитячо-юнацька картинна галерея, дитячо-юнацька студія (хорова, театральна, музична, фольклорна тощо), кімната школяра, курси, студії, школи мистецтв, освітньо-культурні центри національних меншин" + }, + new + { + Id = 13L, + Name = "Інше" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.QuartzJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("LastSuccessLaunch") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("QuartzJobs"); + }); + + 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)") + .HasDefaultValue(false); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("Rate") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EntityId"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ParentId"); + + b.ToTable("Ratings"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.RegionAdmin", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("CATOTTGId") + .HasColumnType("bigint"); + + b.Property("InstitutionId") + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.HasKey("UserId"); + + b.HasIndex("CATOTTGId"); + + b.HasIndex("InstitutionId"); + + b.HasIndex("IsDeleted"); + + b.ToTable("RegionAdmins"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SocialGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("NameEn") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + b.ToTable("SocialGroups"); + + b.HasData( + new + { + Id = 1L, + Name = "Діти із багатодітних сімей", + NameEn = "Children from large families" + }, + new + { + Id = 2L, + Name = "Діти із малозабезпечених сімей", + NameEn = "Children from low-income families" + }, + new + { + Id = 3L, + Name = "Діти з інвалідністю", + NameEn = "Children with disabilities" + }, + new + { + Id = 4L, + Name = "Діти-сироти", + NameEn = "Orphans" + }, + new + { + Id = 5L, + Name = "Діти, позбавлені батьківського піклування", + NameEn = "Children deprived of parental care" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.StatisticReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("ExternalStorageId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ReportDataType") + .HasColumnType("int"); + + b.Property("ReportType") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.HasKey("Id"); + + b.ToTable("StatisticReports"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.StatisticReportCSV", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ApplicationsAmount") + .HasColumnType("int"); + + b.Property("ApplicationsApproved") + .HasColumnType("int"); + + b.Property("CATOTTGCategory") + .HasColumnType("longtext"); + + b.Property("CATOTTGCode") + .HasColumnType("longtext"); + + b.Property("ChildrenStudying") + .HasColumnType("int"); + + b.Property("ChildrenStudyingAchievementsInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("ChildrenStudyingDisabilityInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("ChildrenStudyingFemale") + .HasColumnType("int"); + + b.Property("ChildrenStudyingFemaleInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("ChildrenStudyingInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("ChildrenStudyingLargeFamilyInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("ChildrenStudyingLess18") + .HasColumnType("int"); + + b.Property("ChildrenStudyingOrphanInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("ChildrenStudyingPoorFamilyInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("Complex") + .HasColumnType("longtext"); + + b.Property("EDRPOU") + .HasColumnType("longtext"); + + b.Property("InstitutionTitle") + .HasColumnType("longtext"); + + b.Property("ProviderId") + .HasColumnType("binary(16)"); + + b.Property("ProviderName") + .HasColumnType("longtext"); + + b.Property("ProviderType") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Settlement") + .HasColumnType("longtext"); + + b.Property("Status") + .HasColumnType("longtext"); + + b.Property("Teachers") + .HasColumnType("int"); + + b.Property("TeachersFrom31To40InstitutionHierarchy") + .HasColumnType("int"); + + b.Property("TeachersFrom41To50InstitutionHierarchy") + .HasColumnType("int"); + + b.Property("TeachersFrom51To55InstitutionHierarchy") + .HasColumnType("int"); + + b.Property("TeachersFrom55InstitutionHierarchy") + .HasColumnType("int"); + + b.Property("TeachersInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("TeachersLess30InstitutionHierarchy") + .HasColumnType("int"); + + b.Property("TerritorialCommunity") + .HasColumnType("longtext"); + + b.Property("WorkshopsAmount") + .HasColumnType("int"); + + b.Property("WorkshopsAmountInstitutionHierarchy") + .HasColumnType("int"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("StatisticReportsCSV"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SubordinationStructure.Institution", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("IsGovernment") + .HasColumnType("tinyint(1)"); + + b.Property("NumberOfHierarchyLevels") + .HasColumnType("int"); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("Title") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("InstitutionId"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("ParentId") + .HasColumnType("binary(16)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("InstitutionId"); + + b.HasIndex("IsDeleted"); + + 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(60) + .HasColumnType("varchar(60)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("MiddleName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + 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(60) + .HasColumnType("varchar(60)"); + + b.Property("IsBlocked") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("IsDerived") + .HasColumnType("tinyint(1)"); + + b.Property("IsRegistered") + .HasColumnType("tinyint(1)"); + + b.Property("LastLogin") + .HasColumnType("datetime(6)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("MiddleName") + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("MustChangePassword") + .HasColumnType("tinyint(1)"); + + 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("IsDeleted"); + + 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("CompetitiveSelection") + .HasColumnType("tinyint(1)"); + + b.Property("CompetitiveSelectionDescription") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("CoverImageId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + 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("IsBlocked") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + 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(120) + .HasColumnType("varchar(120)"); + + 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("InstitutionHierarchyId"); + + b.HasIndex("IsDeleted"); + + 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)") + .HasDefaultValue(false); + + b.Property("SectionName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("WorkshopId") + .HasColumnType("binary(16)"); + + b.HasKey("Id"); + + b.HasIndex("IsDeleted"); + + 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("ChildSocialGroup", b => + { + b.HasOne("OutOfSchool.Services.Models.Child", null) + .WithMany() + .HasForeignKey("ChildrenId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.SocialGroup", null) + .WithMany() + .HasForeignKey("SocialGroupsId") + .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.CATOTTG", "CATOTTG") + .WithMany() + .HasForeignKey("CATOTTGId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("CATOTTG"); + }); + + 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.AreaAdmin", b => + { + b.HasOne("OutOfSchool.Services.Models.CATOTTG", "CATOTTG") + .WithMany() + .HasForeignKey("CATOTTGId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.Institution", "Institution") + .WithMany() + .HasForeignKey("InstitutionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CATOTTG"); + + b.Navigation("Institution"); + + b.Navigation("User"); + }); + + 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.CATOTTG", b => + { + b.HasOne("OutOfSchool.Services.Models.CATOTTG", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + 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.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.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.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Institution"); + + b.Navigation("User"); + }); + + 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") + .WithOne() + .HasForeignKey("OutOfSchool.Services.Models.Provider", "ActualAddressId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.Institution", "Institution") + .WithMany("RelatedProviders") + .HasForeignKey("InstitutionId"); + + b.HasOne("OutOfSchool.Services.Models.InstitutionStatus", "InstitutionStatus") + .WithMany("Providers") + .HasForeignKey("InstitutionStatusId"); + + b.HasOne("OutOfSchool.Services.Models.Address", "LegalAddress") + .WithOne() + .HasForeignKey("OutOfSchool.Services.Models.Provider", "LegalAddressId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.ProviderType", "Type") + .WithMany("Providers") + .HasForeignKey("TypeId") + .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("Type"); + + 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.RegionAdmin", b => + { + b.HasOne("OutOfSchool.Services.Models.CATOTTG", "CATOTTG") + .WithMany() + .HasForeignKey("CATOTTGId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.SubordinationStructure.Institution", "Institution") + .WithMany() + .HasForeignKey("InstitutionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CATOTTG"); + + b.Navigation("Institution"); + + b.Navigation("User"); + }); + + 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.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("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.CompanyInformation", b => + { + b.Navigation("CompanyInformationItems"); + }); + + 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.ProviderType", b => + { + b.Navigation("Providers"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SubordinationStructure.Institution", b => + { + b.Navigation("RelatedProviders"); + }); + + 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.Migrations/Data/Migrations/OutOfSchoolMigrations/20230925195746_RemoveSoftDeleteQuartzJob.cs b/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/20230925195746_RemoveSoftDeleteQuartzJob.cs new file mode 100644 index 0000000000..e5b01c5aaa --- /dev/null +++ b/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/20230925195746_RemoveSoftDeleteQuartzJob.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace OutOfSchool.Migrations.Data.Migrations.OutOfSchoolMigrations; + +public partial class RemoveSoftDeleteQuartzJob : Migration +{ + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_QuartzJobs_IsDeleted", + table: "QuartzJobs"); + + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "QuartzJobs"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "QuartzJobs", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.CreateIndex( + name: "IX_QuartzJobs_IsDeleted", + table: "QuartzJobs", + column: "IsDeleted"); + } +} diff --git a/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs b/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs index 981f1027b1..55d0833968 100644 --- a/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs +++ b/OutOfSchool/OutOfSchool.Migrations/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs @@ -1545,11 +1545,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("bigint"); - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnType("tinyint(1)") - .HasDefaultValue(false); - b.Property("LastSuccessLaunch") .HasColumnType("datetime(6)"); @@ -1558,8 +1553,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("IsDeleted"); - b.ToTable("QuartzJobs"); }); diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/RatingDTO.cs b/OutOfSchool/OutOfSchool.WebApi/Models/RatingDTO.cs index 0f10024c13..f7a1985276 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/RatingDTO.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/RatingDTO.cs @@ -1,10 +1,8 @@ -using System; -using System.ComponentModel.DataAnnotations; -using OutOfSchool.Services.Enums; +using System.ComponentModel.DataAnnotations; namespace OutOfSchool.WebApi.Models; -public class RatingDto +public class RatingDto : IDto { public long Id { get; set; } diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/AverageRatings/AverageRatingService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/AverageRatings/AverageRatingService.cs index 7c0cc05f61..b7ff3788ab 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/AverageRatings/AverageRatingService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/AverageRatings/AverageRatingService.cs @@ -1,17 +1,8 @@ using AutoMapper; -using Microsoft.EntityFrameworkCore.Storage; -using Nest; using NuGet.Packaging; -using OutOfSchool.ElasticsearchData.Models; using OutOfSchool.Services.Enums; -using OutOfSchool.Services.Models; -using OutOfSchool.Services.Repository; using OutOfSchool.WebApi.Common.QuartzConstants; using OutOfSchool.WebApi.Models; -using System.Collections.Generic; -using System.Drawing.Text; -using System.Linq; -using System.Net.WebSockets; namespace OutOfSchool.WebApi.Services.AverageRatings; @@ -19,20 +10,20 @@ public class AverageRatingService : IAverageRatingService { private readonly ILogger logger; private readonly IMapper mapper; - private readonly IEntityRepository averageRatingRepository; + private readonly IEntityRepositorySoftDeleted averageRatingRepository; private readonly IRatingService ratingService; private readonly IWorkshopRepository workshopRepository; - private readonly IEntityRepository ratingRepository; + private readonly IEntityRepositorySoftDeleted ratingRepository; private readonly IEntityRepository quartzJobRepository; private readonly IOperationWithObjectService operationWithObjectService; public AverageRatingService( ILogger logger, IMapper mapper, - IEntityRepository averageRatingRepository, + IEntityRepositorySoftDeleted averageRatingRepository, IRatingService ratingService, IWorkshopRepository workshopRepository, - IEntityRepository ratingRepository, + IEntityRepositorySoftDeleted ratingRepository, IEntityRepository quartzJobRepository, IOperationWithObjectService operationWithObjectService) { @@ -250,7 +241,7 @@ private async Task RatingsWereDeleted() { var filter = new OperationWithObjectFilter() { - OperationType = OperationWithObjectOperationType.RecalculateAverageRating + OperationType = OperationWithObjectOperationType.RecalculateAverageRating, }; return await operationWithObjectService.Exists(filter); diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/RatingService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/RatingService.cs index c045575078..68e690deb1 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/RatingService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/RatingService.cs @@ -1,18 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Threading.Tasks; +using System.Linq.Expressions; using AutoMapper; using Castle.Core.Internal; using Microsoft.Extensions.Localization; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.ObjectPool; -using Nest; using OutOfSchool.Services.Enums; -using OutOfSchool.Services.Models; -using OutOfSchool.Services.Repository; -using OutOfSchool.WebApi.Extensions; using OutOfSchool.WebApi.Models; namespace OutOfSchool.WebApi.Services; @@ -22,7 +12,7 @@ namespace OutOfSchool.WebApi.Services; /// public class RatingService : IRatingService { - private readonly IEntityRepository ratingRepository; + private readonly IEntityRepositorySoftDeleted ratingRepository; private readonly IWorkshopRepository workshopRepository; private readonly IParentRepository parentRepository; private readonly ILogger logger; @@ -41,7 +31,7 @@ public class RatingService : IRatingService /// Mapper. /// Service operation with rating. public RatingService( - IEntityRepository ratingRepository, + IEntityRepositorySoftDeleted ratingRepository, IWorkshopRepository workshopRepository, IParentRepository parentRepository, ILogger logger, @@ -209,7 +199,7 @@ public async Task Update(RatingDto dto) if (await CheckRatingUpdate(dto).ConfigureAwait(false)) { - var rating = await ratingRepository.Update(mapper.Map(dto)).ConfigureAwait(false); + var rating = await ratingRepository.ReadAndUpdateWith(dto, mapper.Map).ConfigureAwait(false); logger.LogInformation($"Rating with Id = {rating?.Id} updated succesfully."); diff --git a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs index 685e745066..98817ce89a 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs @@ -180,13 +180,12 @@ public MappingProfile() CreateMap(); - CreateMap() + CreateSoftDeletedMap() .ForMember(dest => dest.CoverImageId, opt => opt.Ignore()) .ForMember(dest => dest.WorkshopId, opt => opt.Ignore()) .ForMember(dest => dest.Images, opt => opt.Ignore()) .ForMember(dest => dest.Workshop, opt => opt.Ignore()) - .ForMember(dest => dest.MiddleName, opt => opt.MapFrom(src => src.MiddleName ?? string.Empty)) - .ForMember(dest => dest.IsDeleted, opt => opt.Ignore()); + .ForMember(dest => dest.MiddleName, opt => opt.MapFrom(src => src.MiddleName ?? string.Empty)); CreateMap() .ForMember(dest => dest.CoverImage, opt => opt.Ignore()) @@ -312,9 +311,8 @@ public MappingProfile() .ForMember(dest => dest.PhoneNumber, opt => opt.MapFrom(src => src.PhoneNumber.Right(Constants.PhoneShortLength))) .ForMember(dest => dest.MiddleName, opt => opt.MapFrom(src => src.MiddleName ?? string.Empty)); - CreateMap() - .ForMember(dest => dest.InstitutionHierarchies, opt => opt.Ignore()) - .ForMember(dest => dest.IsDeleted, opt => opt.Ignore()); + CreateSoftDeletedMap() + .ForMember(dest => dest.InstitutionHierarchies, opt => opt.Ignore()); CreateMap() .ForMember(dest => dest.WorkshopsCount, opt => opt.Ignore()); @@ -516,19 +514,16 @@ public MappingProfile() CreateMap(); - CreateMap() - .ForMember(dest => dest.IsDeleted, opt => opt.Ignore()) + CreateSoftDeletedMap() .ForMember(dest => dest.Workshop, opt => opt.Ignore()) .ForMember(dest => dest.AchievementType, opt => opt.Ignore()); CreateMap(); - CreateMap() - .ForMember(dest => dest.IsDeleted, opt => opt.Ignore()) + CreateSoftDeletedMap() .ForMember(dest => dest.Achievement, opt => opt.Ignore()); - CreateMap() - .ForMember(dest => dest.IsDeleted, opt => opt.Ignore()) + CreateSoftDeletedMap() .ForMember(dest => dest.Children, opt => opt.Ignore()) .ForMember(dest => dest.Workshop, opt => opt.Ignore()) .ForMember(dest => dest.AchievementType, opt => opt.Ignore()) @@ -578,7 +573,8 @@ public MappingProfile() CreateMap() .ForMember(dest => dest.FirstName, opt => opt.Ignore()) .ForMember(dest => dest.LastName, opt => opt.Ignore()); - CreateMap() + + CreateSoftDeletedMap() .ForMember(dest => dest.Parent, opt => opt.Ignore()); CreateMap(); @@ -648,4 +644,10 @@ public MappingProfile() CreateMap() .ForMember(dest => dest.SettlementsIds, opt => opt.Ignore()); } + + private IMappingExpression CreateSoftDeletedMap() + where TSource : class + where TDestination : class, ISoftDeleted + => CreateMap() + .ForMember(dest => dest.IsDeleted, opt => opt.Ignore()); } \ No newline at end of file