From 1036ac7b356f81093fe7fafd14fec0d720f8715c Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 7 Feb 2022 01:50:16 +0200 Subject: [PATCH 1/4] Added workshop cover image --- .../OutOfSchool.DataAccess/Models/Workshop.cs | 2 +- ...20205131231_WorkshopCoverImage.Designer.cs | 1465 +++++++++++++++++ .../20220205131231_WorkshopCoverImage.cs | 23 + .../OutOfSchoolDbContextModelSnapshot.cs | 8 +- .../Controllers/ApplicationControllerTests.cs | 12 +- .../Controllers/WorkshopControllerTests.cs | 12 +- .../Extensions/MappingExtensionsTests.cs | 4 +- .../Services/Database/WorkshopServiceTests.cs | 2 +- .../Controllers/V2/TeacherController.cs | 1 - .../Controllers/V2/WorkshopController.cs | 18 +- .../Extensions/MappingExtensions.cs | 4 +- .../Images/SingleImageRemovingResponse.cs | 10 + .../Images/SingleImageUploadingResponse.cs | 10 + .../Models/Teachers/TeacherCreationDto.cs | 2 +- .../Teachers/TeacherCreationResponse.cs | 2 +- .../Models/Teachers/TeacherUpdateDto.cs | 2 +- .../Models/Teachers/TeacherUpdateResponse.cs | 4 +- .../Models/Teachers/TeacherUpdateResultDto.cs | 2 - .../Models/Workshop/WorkshopCreationDto.cs | 2 + .../Workshop/WorkshopCreationResponse.cs | 2 + .../Workshop/WorkshopCreationResultDto.cs | 3 + .../Models/Workshop/WorkshopDTO.cs | 2 +- .../Models/Workshop/WorkshopUpdateDto.cs | 2 + .../Models/Workshop/WorkshopUpdateResponse.cs | 4 +- .../Workshop/WorkshopUpdateResultDto.cs | 4 +- .../Services/Database/WorkshopService.cs | 90 +- .../Services/Images/IImageService.cs | 2 + .../Services/Images/ImageService.cs | 22 + .../Services/TeacherService.cs | 70 +- .../ImageResultsHelper.cs | 23 +- .../OutOfSchool.WebApi/Util/MappingProfile.cs | 5 +- .../TestDataGenerators/WorkshopGenerator.cs | 2 +- 32 files changed, 1688 insertions(+), 128 deletions(-) create mode 100644 OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs create mode 100644 OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs create mode 100644 OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageRemovingResponse.cs create mode 100644 OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageUploadingResponse.cs diff --git a/OutOfSchool/OutOfSchool.DataAccess/Models/Workshop.cs b/OutOfSchool/OutOfSchool.DataAccess/Models/Workshop.cs index 960c9d2c2e..9343afe34e 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Models/Workshop.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Models/Workshop.cs @@ -69,7 +69,7 @@ public class Workshop : IKeyedEntity, IImageDependentEntity public string DisabilityOptionsDesc { get; set; } = string.Empty; [MaxLength(256)] - public string Logo { get; set; } = string.Empty; + public string CoverImageId { get; set; } = string.Empty; [Required(ErrorMessage = "Head's information is required")] [MaxLength(50, ErrorMessage = "Field should not be longer than 50 characters")] diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs new file mode 100644 index 0000000000..84d7c5a1af --- /dev/null +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs @@ -0,0 +1,1465 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using OutOfSchool.Services; + +namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations +{ + [DbContext(typeof(OutOfSchoolDbContext))] + [Migration("20220205131231_WorkshopCoverImage")] + partial class WorkshopCoverImage + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("AboutPortal"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortalItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AboutPortalId") + .HasColumnType("binary(16)"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("SectionName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("AboutPortalId"); + + b.ToTable("AboutPortalItems"); + }); + + 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("District") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + 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.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("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.ChatWorkshop.ChatMessageWorkshop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("ChatRoomId") + .HasColumnType("binary(16)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + 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("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("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.Property("SocialGroupId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("SocialGroupId"); + + b.ToTable("Children"); + }); + + 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("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("Title") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.HasKey("Id"); + + b.HasIndex("DepartmentId"); + + b.ToTable("Classes"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.DateTimeRange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("EndTime") + .HasColumnType("time(6)"); + + 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("Title") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + 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("Title") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + 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("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("WorkshopImages"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.InstitutionStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + 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 = "Має намір на реорганізацію" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Parent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + 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("Description") + .IsRequired() + .HasMaxLength(500) + .IsUnicode(true) + .HasColumnType("varchar(500)"); + + 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("InstitutionStatusId") + .HasColumnType("bigint"); + + b.Property("LegalAddressId") + .HasColumnType("bigint"); + + 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") + .HasColumnType("tinyint(1)"); + + 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("InstitutionStatusId"); + + b.HasIndex("LegalAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("Providers"); + }); + + 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("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("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.SupportInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Description") + .HasMaxLength(3000) + .HasColumnType("varchar(3000)"); + + b.Property("SectionName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("SupportInformation"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Teacher", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AvatarImageId") + .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("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("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(true); + + 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"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AddressId") + .HasColumnType("bigint"); + + b.Property("ClassId") + .HasColumnType("bigint"); + + b.Property("CoverImageId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DepartmentId") + .HasColumnType("bigint"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + 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("Head") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("HeadDateOfBirth") + .HasColumnType("date"); + + b.Property("Instagram") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("IsPerMonth") + .HasColumnType("tinyint(1)"); + + b.Property("Keywords") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("MaxAge") + .HasColumnType("int"); + + b.Property("MinAge") + .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("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("ProviderId"); + + b.ToTable("Workshops"); + }); + + 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.AboutPortalItem", b => + { + b.HasOne("OutOfSchool.Services.Models.AboutPortal", "AboutPortal") + .WithMany("AboutPortalItems") + .HasForeignKey("AboutPortalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AboutPortal"); + }); + + 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.NoAction) + .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.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.HasOne("OutOfSchool.Services.Models.SocialGroup", "SocialGroup") + .WithMany("Children") + .HasForeignKey("SocialGroupId"); + + b.Navigation("Parent"); + + 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.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.Workshop", "Entity") + .WithMany("Images") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Entity"); + }); + + 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.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("InstitutionStatus"); + + b.Navigation("LegalAddress"); + + b.Navigation("User"); + }); + + 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.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.NoAction) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") + .WithMany("Workshops") + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Address"); + + b.Navigation("Class"); + + b.Navigation("Direction"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortal", b => + { + b.Navigation("AboutPortalItems"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatRoomWorkshop", b => + { + b.Navigation("ChatMessages"); + }); + + 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("Workshops"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SocialGroup", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => + { + b.Navigation("Applications"); + + b.Navigation("ChatRooms"); + + b.Navigation("DateTimeRanges"); + + b.Navigation("Images"); + + b.Navigation("Teachers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs new file mode 100644 index 0000000000..d7b0bba69c --- /dev/null +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations +{ + public partial class WorkshopCoverImage : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Logo", + table: "Workshops", + newName: "CoverImageId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "CoverImageId", + table: "Workshops", + newName: "Logo"); + } + } +} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs index e1568c62fc..956a66f4f5 100644 --- a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs @@ -1010,6 +1010,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ClassId") .HasColumnType("bigint"); + b.Property("CoverImageId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + b.Property("DepartmentId") .HasColumnType("bigint"); @@ -1053,10 +1057,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(200) .HasColumnType("varchar(200)"); - b.Property("Logo") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - b.Property("MaxAge") .HasColumnType("int"); diff --git a/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/ApplicationControllerTests.cs b/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/ApplicationControllerTests.cs index 2909c7044c..a9ec677abd 100644 --- a/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/ApplicationControllerTests.cs +++ b/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/ApplicationControllerTests.cs @@ -543,7 +543,7 @@ private WorkshopDTO FakeWorkshop() Email = "email6@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image6", + CoverImageId = "image6", ProviderId = Guid.NewGuid(), DirectionId = 1, DepartmentId = 1, @@ -611,7 +611,7 @@ private List FakeWorkshops() Email = "email1@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image1", + CoverImageId = "image1", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -639,7 +639,7 @@ private List FakeWorkshops() Email = "email2@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image2", + CoverImageId = "image2", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -667,7 +667,7 @@ private List FakeWorkshops() Email = "email3@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image3", + CoverImageId = "image3", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -691,7 +691,7 @@ private List FakeWorkshops() Email = "email4@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image4", + CoverImageId = "image4", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -715,7 +715,7 @@ private List FakeWorkshops() Email = "email5@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image5", + CoverImageId = "image5", DirectionId = 1, DepartmentId = 1, ClassId = 1, diff --git a/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/WorkshopControllerTests.cs b/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/WorkshopControllerTests.cs index 4c02bf2955..b56a5a1740 100644 --- a/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/WorkshopControllerTests.cs +++ b/OutOfSchool/OutOfSchool.WebApi.Tests/Controllers/WorkshopControllerTests.cs @@ -417,7 +417,7 @@ private WorkshopDTO FakeWorkshop() Email = "email6@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image6", + CoverImageId = "image6", ProviderId = new Guid("5e519d63-0cdd-48a8-81da-6365aa5ad8c3"), DirectionId = 1, DepartmentId = 1, @@ -485,7 +485,7 @@ private List FakeWorkshops() Email = "email1@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image1", + CoverImageId = "image1", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -513,7 +513,7 @@ private List FakeWorkshops() Email = "email2@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image2", + CoverImageId = "image2", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -541,7 +541,7 @@ private List FakeWorkshops() Email = "email3@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image3", + CoverImageId = "image3", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -565,7 +565,7 @@ private List FakeWorkshops() Email = "email4@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image4", + CoverImageId = "image4", DirectionId = 1, DepartmentId = 1, ClassId = 1, @@ -589,7 +589,7 @@ private List FakeWorkshops() Email = "email5@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image5", + CoverImageId = "image5", DirectionId = 1, DepartmentId = 1, ClassId = 1, diff --git a/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs b/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs index 55841a1a1d..841d65082c 100644 --- a/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs +++ b/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs @@ -258,7 +258,7 @@ public void Mapping_WorkshopDTO_ToCardDto_IsCorrect() Email = "email5@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image5", + CoverImageId = "image5", ProviderId = Guid.NewGuid(), DirectionId = 1, Direction = "Some title of direction", @@ -325,7 +325,7 @@ public void Mapping_WorkshopDTO_ToCardDto_IsCorrect() Assert.AreEqual(workshopDto.ProviderTitle, result.ProviderTitle); Assert.AreEqual(workshopDto.MinAge, result.MinAge); Assert.AreEqual(workshopDto.MaxAge, result.MaxAge); - Assert.AreEqual(workshopDto.Logo, result.Photo); + Assert.AreEqual(workshopDto.CoverImageId, result.Photo); Assert.AreEqual(workshopDto.DirectionId, result.DirectionId); Assert.AreEqual(workshopDto.Address?.Id, result.Address.Id); Assert.IsNotNull(result.Address); diff --git a/OutOfSchool/OutOfSchool.WebApi.Tests/Services/Database/WorkshopServiceTests.cs b/OutOfSchool/OutOfSchool.WebApi.Tests/Services/Database/WorkshopServiceTests.cs index 97cd7d9a21..0be267f7a2 100644 --- a/OutOfSchool/OutOfSchool.WebApi.Tests/Services/Database/WorkshopServiceTests.cs +++ b/OutOfSchool/OutOfSchool.WebApi.Tests/Services/Database/WorkshopServiceTests.cs @@ -474,7 +474,7 @@ private Workshop WithWorkshop(Guid id) Email = "email1@gmail.com", MaxAge = 10, MinAge = 4, - Logo = "image1", + CoverImageId = "image1", ProviderId = new Guid("65eb933f-6502-4e89-a7cb-65901e51d119"), DirectionId = 1, ClassId = 1, diff --git a/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/TeacherController.cs b/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/TeacherController.cs index 7c7db76d8d..430bf0f055 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/TeacherController.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/TeacherController.cs @@ -124,7 +124,6 @@ public async Task Update([FromForm] TeacherUpdateDto dto) { Teacher = updateResult.Teacher, UploadingAvatarImageResult = updateResult.UploadingAvatarImageResult?.CreateSingleUploadingResult(), - RemovingAvatarImageResult = updateResult.RemovingAvatarImageResult?.CreateSingleRemovingResult(), }); } diff --git a/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/WorkshopController.cs b/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/WorkshopController.cs index 6d8e7074f5..cdc629fabe 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/WorkshopController.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Controllers/V2/WorkshopController.cs @@ -183,6 +183,7 @@ public async Task Create([FromForm] WorkshopCreationDto dto) // T new WorkshopCreationResponse { Workshop = creationResult.Workshop, + UploadingCoverImageResult = creationResult.UploadingCoverImageResult?.CreateSingleUploadingResult(), UploadingImagesResults = creationResult.UploadingImagesResults?.CreateMultipleUploadingResult(), }); } @@ -217,12 +218,7 @@ public async Task Update([FromForm] WorkshopUpdateDto dto) var updatingResult = await combinedWorkshopService.Update(dto).ConfigureAwait(false); - return Ok(new WorkshopUpdateResponse - { - Workshop = updatingResult.Workshop, - UploadingImagesResults = updatingResult.UploadingImagesResults?.CreateMultipleUploadingResult(), - RemovingImagesResults = updatingResult.RemovingImagesResults?.CreateMultipleRemovingResult(), - }); + return Ok(CreateUpdateResponse(updatingResult)); } /// @@ -276,5 +272,15 @@ private async Task IsUserProvidersOwner(Guid providerId) return true; } + + private WorkshopUpdateResponse CreateUpdateResponse(WorkshopUpdateResultDto updatingResult) + { + return new WorkshopUpdateResponse + { + Workshop = updatingResult.Workshop, + UploadingCoverImageResult = updatingResult.UploadingCoverImageResult?.CreateSingleUploadingResult(), + UploadingImagesResults = updatingResult.UploadingImagesResults?.CreateMultipleUploadingResult(), + }; + } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs b/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs index ec48c27b82..6e9e3ae19e 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs @@ -380,7 +380,7 @@ public static WorkshopCard ToCardDto(this WorkshopDTO workshopDTO) { cfg.CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.Logo)); + .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.CoverImageId)); }); } @@ -391,7 +391,7 @@ public static WorkshopCard ToCard(this Workshop workshop) cfg.CreateMap(); cfg.CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.Logo)) + .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.CoverImageId)) .ForMember(dest => dest.DirectionId, opt => opt.MapFrom(src => src.Direction.Id)); }); } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageRemovingResponse.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageRemovingResponse.cs new file mode 100644 index 0000000000..d27ab80c1d --- /dev/null +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageRemovingResponse.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using OutOfSchool.WebApi.Common; + +namespace OutOfSchool.WebApi.Models.Images +{ + public class SingleImageRemovingResponse + { + public OperationResult Result { get; set; } + } +} diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageUploadingResponse.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageUploadingResponse.cs new file mode 100644 index 0000000000..41f015a458 --- /dev/null +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Images/SingleImageUploadingResponse.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using OutOfSchool.WebApi.Common; + +namespace OutOfSchool.WebApi.Models.Images +{ + public class SingleImageUploadingResponse + { + public OperationResult Result { get; set; } + } +} diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationDto.cs index 8ff7781981..32110f0a3c 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationDto.cs @@ -5,6 +5,6 @@ namespace OutOfSchool.WebApi.Models.Teachers { public class TeacherCreationDto : TeacherDTO { - public IFormFile ImageFile { get; set; } + public IFormFile AvatarImage { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationResponse.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationResponse.cs index 7131860e80..791db59881 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationResponse.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherCreationResponse.cs @@ -6,6 +6,6 @@ public class TeacherCreationResponse { public TeacherDTO Teacher { get; set; } - public MultipleImageUploadingResponse UploadingAvatarImageResult { get; set; } + public SingleImageUploadingResponse UploadingAvatarImageResult { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateDto.cs index 4b2822edea..6cfbc7cc19 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateDto.cs @@ -4,6 +4,6 @@ namespace OutOfSchool.WebApi.Models.Teachers { public class TeacherUpdateDto : TeacherDTO { - public IFormFile ImageFile { get; set; } + public IFormFile AvatarImage { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResponse.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResponse.cs index cac02d4d8d..f27edf460c 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResponse.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResponse.cs @@ -6,8 +6,6 @@ public class TeacherUpdateResponse { public TeacherDTO Teacher { get; set; } - public MultipleImageUploadingResponse UploadingAvatarImageResult { get; set; } - - public MultipleImageRemovingResponse RemovingAvatarImageResult { get; set; } + public SingleImageUploadingResponse UploadingAvatarImageResult { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResultDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResultDto.cs index 62f686e6b0..d172420f96 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResultDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Teachers/TeacherUpdateResultDto.cs @@ -7,7 +7,5 @@ public class TeacherUpdateResultDto public TeacherDTO Teacher { get; set; } public OperationResult UploadingAvatarImageResult { get; set; } - - public OperationResult RemovingAvatarImageResult { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationDto.cs index 84e5fe8a81..4246363ad6 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationDto.cs @@ -11,6 +11,8 @@ public class WorkshopCreationDto : WorkshopDTO { public List ImageFiles { get; set; } + public IFormFile CoverImage { get; set; } + public new List Teachers { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResponse.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResponse.cs index 6bea33fccf..9aeb610252 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResponse.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResponse.cs @@ -6,6 +6,8 @@ public class WorkshopCreationResponse { public WorkshopDTO Workshop { get; set; } + public SingleImageUploadingResponse UploadingCoverImageResult { get; set; } + public MultipleImageUploadingResponse UploadingImagesResults { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResultDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResultDto.cs index 3a09108c1b..e491b8e98d 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResultDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCreationResultDto.cs @@ -1,4 +1,5 @@ using OutOfSchool.WebApi.Common; +using OutOfSchool.WebApi.Models.Images; namespace OutOfSchool.WebApi.Models.Workshop { @@ -6,6 +7,8 @@ public class WorkshopCreationResultDto { public WorkshopDTO Workshop { get; set; } + public OperationResult UploadingCoverImageResult { get; set; } + public MultipleKeyValueOperationResult UploadingImagesResults { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopDTO.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopDTO.cs index ac2e11b72e..f4982fe764 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopDTO.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopDTO.cs @@ -71,7 +71,7 @@ public class WorkshopDTO : IValidatableObject public string DisabilityOptionsDesc { get; set; } = string.Empty; [MaxLength(256)] - public string Logo { get; set; } = string.Empty; + public string CoverImageId { get; set; } = string.Empty; [Required(ErrorMessage = "Head's information is required")] [MaxLength(50, ErrorMessage = "Field should not be longer than 50 characters")] diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateDto.cs index f28a0a5ab3..8651b5e27e 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateDto.cs @@ -11,6 +11,8 @@ public class WorkshopUpdateDto : WorkshopDTO { public List ImageFiles { get; set; } + public IFormFile CoverImage { get; set; } + public new List Teachers { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResponse.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResponse.cs index 4b4ff636a1..3b7d38d1ec 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResponse.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResponse.cs @@ -6,8 +6,8 @@ public class WorkshopUpdateResponse { public WorkshopDTO Workshop { get; set; } - public MultipleImageUploadingResponse UploadingImagesResults { get; set; } + public SingleImageUploadingResponse UploadingCoverImageResult { get; set; } - public MultipleImageRemovingResponse RemovingImagesResults { get; set; } + public MultipleImageUploadingResponse UploadingImagesResults { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResultDto.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResultDto.cs index 7211ac88b8..4dceaafa08 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResultDto.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopUpdateResultDto.cs @@ -6,8 +6,8 @@ public class WorkshopUpdateResultDto { public WorkshopDTO Workshop { get; set; } - public MultipleKeyValueOperationResult UploadingImagesResults { get; set; } + public OperationResult UploadingCoverImageResult { get; set; } - public MultipleKeyValueOperationResult RemovingImagesResults { get; set; } + public MultipleKeyValueOperationResult UploadingImagesResults { get; set; } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/Database/WorkshopService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/Database/WorkshopService.cs index 6513445442..27384b49f4 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/Database/WorkshopService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/Database/WorkshopService.cs @@ -16,7 +16,9 @@ using OutOfSchool.Services.Repository; using OutOfSchool.WebApi.Common; using OutOfSchool.WebApi.Common.Resources; +using OutOfSchool.WebApi.Common.Resources.Codes; using OutOfSchool.WebApi.Enums; +using OutOfSchool.WebApi.Extensions; using OutOfSchool.WebApi.Models; using OutOfSchool.WebApi.Models.Images; using OutOfSchool.WebApi.Models.Teachers; @@ -117,16 +119,25 @@ public async Task CreateV2(WorkshopCreationDto dto) uploadingResult = await workshopImagesInteractionService.UploadManyImagesAsync(newWorkshop.Id, dto.ImageFiles).ConfigureAwait(false); } + Result uploadingCoverImageResult = null; + if (dto.CoverImage != null) + { + uploadingCoverImageResult = await AddCoverImage(newWorkshop, dto.CoverImage).ConfigureAwait(false); + } + if (dto.Teachers != null) { await AddTeacherImages(newWorkshop, dto.Teachers).ConfigureAwait(false); } + await UpdateWorkshop().ConfigureAwait(false); + logger.LogInformation($"Workshop with Id = {newWorkshop.Id} created successfully."); return new WorkshopCreationResultDto { Workshop = mapper.Map(newWorkshop), + UploadingCoverImageResult = uploadingCoverImageResult?.OperationResult, UploadingImagesResults = uploadingResult?.MultipleKeyValueOperationResult, }; } @@ -248,24 +259,19 @@ public async Task UpdateV2(WorkshopUpdateDto dto) dto.AddressId = currentWorkshop.AddressId; dto.Address.Id = currentWorkshop.AddressId; - await UpdateTeachers(currentWorkshop, dto.Teachers ?? new List()).ConfigureAwait(false); + await ChangeTeachers(currentWorkshop, dto.Teachers ?? new List()).ConfigureAwait(false); mapper.Map(dto, currentWorkshop); - try - { - await workshopRepository.UnitOfWork.CompleteAsync().ConfigureAwait(false); - } - catch (DbUpdateConcurrencyException exception) - { - logger.LogError(exception, $"Updating failed. Exception: {exception.Message}"); - throw; - } + + var changingCoverImageResult = await ChangeCoverImage(currentWorkshop, dto.CoverImageId, dto.CoverImage).ConfigureAwait(false); + + await UpdateWorkshop().ConfigureAwait(false); return new WorkshopUpdateResultDto { Workshop = mapper.Map(currentWorkshop), + UploadingCoverImageResult = changingCoverImageResult?.UploadingResult?.OperationResult, UploadingImagesResults = multipleImageChangingResult.UploadedMultipleResult?.MultipleKeyValueOperationResult, - RemovingImagesResults = multipleImageChangingResult.RemovedMultipleResult?.MultipleKeyValueOperationResult, }; } @@ -322,6 +328,16 @@ public async Task DeleteV2(Guid id) throw new InvalidOperationException($"Unreal to delete {nameof(Workshop)} [id = {id}] because unable to delete images."); } + if (!string.IsNullOrEmpty(entity.CoverImageId)) + { + var removingCoverImageResult = await imageService.RemoveImageAsync(entity.CoverImageId).ConfigureAwait(false); + + if (!removingCoverImageResult.Succeeded) + { + throw new InvalidOperationException($"Unreal to delete {nameof(Workshop)} [id = {id}] because unable to delete cover image."); + } + } + foreach (var teacher in entity.Teachers.ToList()) { await teacherService.Delete(teacher.Id).ConfigureAwait(false); @@ -596,6 +612,18 @@ private List GetWorkshopsWithAverageRating(List worksh return workshops; } + private async Task> AddCoverImage(Workshop workshop, IFormFile image) + { + var uploadingCoverImageResult = await imageService.UploadImageAsync(image).ConfigureAwait(false); + + if (uploadingCoverImageResult.Succeeded) + { + workshop.CoverImageId = uploadingCoverImageResult.Value; + } + + return uploadingCoverImageResult; + } + private async Task AddTeacherImages(Workshop workshop, List teacherCreationDtoList) { if (teacherCreationDtoList.Count != workshop.Teachers.Count) @@ -605,7 +633,7 @@ private async Task AddTeacherImages(Workshop workshop, List for (var i = 0; i < teacherCreationDtoList.Count; i++) { - var image = teacherCreationDtoList[i].ImageFile; + var image = teacherCreationDtoList[i].AvatarImage; if (image != null) { var uploadingImageResult = await imageService @@ -617,19 +645,28 @@ private async Task AddTeacherImages(Workshop workshop, List } } } + } - try - { - await workshopRepository.UnitOfWork.CompleteAsync().ConfigureAwait(false); - } - catch (DbUpdateException ex) + private async Task ChangeCoverImage(Workshop workshop, string dtoImageId, IFormFile newImage) + { + ImageChangingResult changingCoverImageResult = null; + if (!string.Equals(dtoImageId, workshop.CoverImageId, StringComparison.Ordinal) + || (string.IsNullOrEmpty(dtoImageId) && newImage != null)) { - logger.LogError(ex, $"Updating a new workshop failed. Exception: {ex.Message}"); - throw; + changingCoverImageResult = await imageService.ChangeImageAsync(workshop.CoverImageId, newImage).ConfigureAwait(false); + + workshop.CoverImageId = changingCoverImageResult.UploadingResult switch + { + null when changingCoverImageResult.RemovingResult is { Succeeded: false } => workshop.CoverImageId, + { Succeeded: true } => changingCoverImageResult.UploadingResult.Value, + _ => null + }; } + + return changingCoverImageResult; } - private async Task UpdateTeachers(Workshop currentWorkshop, List teacherUpdateDtoList) + private async Task ChangeTeachers(Workshop currentWorkshop, List teacherUpdateDtoList) { var deletedIds = currentWorkshop.Teachers.Select(x => x.Id).Except(teacherUpdateDtoList.Select(x => x.Id)).ToList(); @@ -652,5 +689,18 @@ private async Task UpdateTeachers(Workshop currentWorkshop, ListImage Id. /// The that represents the asynchronous operation, containing the of the operation. Task RemoveImageAsync(string imageId); + + Task ChangeImageAsync(string currentImage, IFormFile newImage); } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs index 04bf80fa34..b6bb1c4b00 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs @@ -210,6 +210,28 @@ public async Task RemoveImageAsync(string imageId) return await RemovingImageProcessAsync(imageId).ConfigureAwait(false); } + public async Task ChangeImageAsync(string currentImage, IFormFile newImage) + { + var result = new ImageChangingResult(); + if (!string.IsNullOrEmpty(currentImage)) + { + result.RemovingResult = await RemoveImageAsync(currentImage).ConfigureAwait(false); + if (!result.RemovingResult.Succeeded) + { + return new ImageChangingResult { RemovingResult = OperationResult.Failed(ImagesOperationErrorCode.RemovingError.GetOperationError()) }; + } + + currentImage = null; + } + + if (string.IsNullOrEmpty(currentImage) && newImage != null) + { + result.UploadingResult = await UploadImageAsync(newImage).ConfigureAwait(false); + } + + return result; + } + private async Task> UploadImageProcessAsync(Stream contentStream, string contentType) { try diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/TeacherService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/TeacherService.cs index 1493266f89..b201c1efce 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/TeacherService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/TeacherService.cs @@ -57,10 +57,11 @@ public async Task Create(TeacherCreationDto dto) var newTeacher = await teacherRepository.Create(teacher).ConfigureAwait(false); - var uploadingResult = await imageService.UploadImageAsync(dto.ImageFile).ConfigureAwait(false); + var uploadingResult = await imageService.UploadImageAsync(dto.AvatarImage).ConfigureAwait(false); if (uploadingResult.Succeeded) { - await UpdateTeacherAvatarAsync(newTeacher, uploadingResult.Value).ConfigureAwait(false); + teacher.AvatarImageId = uploadingResult.Value; + await UpdateTeacher().ConfigureAwait(false); } logger.LogInformation($"Teacher with Id = {newTeacher.Id} created successfully."); @@ -105,35 +106,18 @@ public async Task Update(TeacherUpdateDto dto) logger.LogInformation($"Updating Teacher with Id = {dto.Id} started."); var teacher = await teacherRepository.GetById(dto.Id).ConfigureAwait(false); - var currentImageId = teacher.AvatarImageId; + mapper.Map(dto, teacher); - var changingAvatarResult = await ChangeAvatarImageAsync(currentImageId, dto.AvatarImageId, dto.ImageFile).ConfigureAwait(false); - teacher.AvatarImageId = changingAvatarResult.UploadingResult switch - { - null when changingAvatarResult.RemovingResult == null => currentImageId, - { Succeeded: true } => changingAvatarResult.UploadingResult.Value, - _ => null - }; + var changingAvatarResult = await ChangeAvatarImage(teacher, dto.AvatarImageId, dto.AvatarImage).ConfigureAwait(false); - try - { - await teacherRepository.UnitOfWork.CompleteAsync().ConfigureAwait(false); + await UpdateTeacher().ConfigureAwait(false); - logger.LogInformation($"Teacher with Id = {teacher.Id} updated successfully."); - - return new TeacherUpdateResultDto - { - Teacher = mapper.Map(teacher), - UploadingAvatarImageResult = changingAvatarResult.UploadingResult?.OperationResult, - RemovingAvatarImageResult = changingAvatarResult.RemovingResult, - }; - } - catch (DbUpdateConcurrencyException) + return new TeacherUpdateResultDto { - logger.LogError($"Updating failed. Teacher with Id = {dto.Id} doesn't exist in the system."); - throw; - } + Teacher = mapper.Map(teacher), + UploadingAvatarImageResult = changingAvatarResult?.UploadingResult?.OperationResult, + }; } /// @@ -166,40 +150,34 @@ public async Task Delete(Guid id) } } - private async Task ChangeAvatarImageAsync(string currentAvatarId, string oldImage, IFormFile newImage) + private async Task ChangeAvatarImage(Teacher teacher, string dtoImageId, IFormFile newImage) { - var result = new ImageChangingResult(); - if (!string.IsNullOrEmpty(currentAvatarId) && !currentAvatarId.Equals(oldImage, StringComparison.Ordinal)) + ImageChangingResult changingAvatarResult = null; + if (!string.Equals(dtoImageId, teacher.AvatarImageId, StringComparison.Ordinal) + || (string.IsNullOrEmpty(dtoImageId) && newImage != null)) { - result.RemovingResult = await imageService.RemoveImageAsync(currentAvatarId).ConfigureAwait(false); - if (!result.RemovingResult.Succeeded) - { - return new ImageChangingResult { RemovingResult = OperationResult.Failed(ImagesOperationErrorCode.RemovingError.GetOperationError()) }; - } + changingAvatarResult = await imageService.ChangeImageAsync(teacher.AvatarImageId, newImage).ConfigureAwait(false); - currentAvatarId = null; - } - - if (string.IsNullOrEmpty(currentAvatarId)) - { - result.UploadingResult = await imageService.UploadImageAsync(newImage).ConfigureAwait(false); + teacher.AvatarImageId = changingAvatarResult.UploadingResult switch + { + null when changingAvatarResult.RemovingResult is { Succeeded: false } => teacher.AvatarImageId, + { Succeeded: true } => changingAvatarResult.UploadingResult.Value, + _ => null + }; } - return result; + return changingAvatarResult; } - // delete id if exception - private async Task UpdateTeacherAvatarAsync(Teacher teacher, string newImageId) + private async Task UpdateTeacher() { - teacher.AvatarImageId = newImageId; - try { await teacherRepository.UnitOfWork.CompleteAsync().ConfigureAwait(false); } catch (DbUpdateException ex) { - logger.LogError(ex, "Unreal to update entity while operating with images."); + logger.LogError(ex, "Unreal to update teacher."); throw; } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Util/ControllersResultsHelpers/ImageResultsHelper.cs b/OutOfSchool/OutOfSchool.WebApi/Util/ControllersResultsHelpers/ImageResultsHelper.cs index 31ec4e6714..974b97c88a 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Util/ControllersResultsHelpers/ImageResultsHelper.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Util/ControllersResultsHelpers/ImageResultsHelper.cs @@ -36,29 +36,23 @@ public static MultipleImageRemovingResponse CreateMultipleRemovingResult(this Mu }; } - public static MultipleImageUploadingResponse CreateSingleUploadingResult(this OperationResult result) + public static SingleImageUploadingResponse CreateSingleUploadingResult(this OperationResult result) { _ = result ?? throw new ArgumentNullException(nameof(result)); - return new MultipleImageUploadingResponse + return new SingleImageUploadingResponse() { - AllImagesUploaded = result.Succeeded, - GeneralMessage = result.Succeeded ? null : result.Errors.FirstOrDefault()?.Description, - HasResults = true, - Results = CreateSingleResultResponse(result), + Result = result, }; } - public static MultipleImageRemovingResponse CreateSingleRemovingResult(this OperationResult result) + public static SingleImageRemovingResponse CreateSingleRemovingResult(this OperationResult result) { _ = result ?? throw new ArgumentNullException(nameof(result)); - return new MultipleImageRemovingResponse + return new SingleImageRemovingResponse() { - AllImagesRemoved = result.Succeeded, - GeneralMessage = result.Succeeded ? null : result.Errors.FirstOrDefault()?.Description, - HasResults = true, - Results = CreateSingleResultResponse(result), + Result = result, }; } @@ -71,10 +65,5 @@ private static IDictionary CreateResultsResponse(Multipl return multipleResults.HasResults ? multipleResults.Results : null; } - - private static IDictionary CreateSingleResultResponse(OperationResult result) - { - return result.Succeeded ? null : new Dictionary { { 0, result } }; - } } } diff --git a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs index 9b9b0468b7..ba13375794 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs @@ -46,7 +46,8 @@ public MappingProfile() var dtoTeachers = ctx.Mapper.Map>(dto.Teachers); return WorkshopTeachersMapperFunction(dtoTeachers, dest); })) - .ForMember(dest => dest.Images, opt => opt.Ignore()); + .ForMember(dest => dest.Images, opt => opt.Ignore()) + .ForMember(dest => dest.CoverImageId, opt => opt.Ignore()); CreateMap() .IncludeBase() @@ -104,7 +105,7 @@ public MappingProfile() .ForMember(dest => dest.Direction, opt => opt.Ignore()); CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.Logo)) + .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.CoverImageId)) .ForMember(dest => dest.DirectionId, opt => opt.MapFrom(src => src.Direction.Id)); CreateMap().ReverseMap() .ForMember(c => c.Parent, m => m.Ignore()); diff --git a/OutOfSchool/Tests/OutOfSchool.Tests.Common/TestDataGenerators/WorkshopGenerator.cs b/OutOfSchool/Tests/OutOfSchool.Tests.Common/TestDataGenerators/WorkshopGenerator.cs index 992bfa740b..75c0e2289d 100644 --- a/OutOfSchool/Tests/OutOfSchool.Tests.Common/TestDataGenerators/WorkshopGenerator.cs +++ b/OutOfSchool/Tests/OutOfSchool.Tests.Common/TestDataGenerators/WorkshopGenerator.cs @@ -24,7 +24,7 @@ public static class WorkshopGenerator .RuleFor(x => x.Description, f => f.Lorem.Paragraph()) .RuleFor(x => x.WithDisabilityOptions, f => f.Random.Bool()) .RuleFor(x => x.DisabilityOptionsDesc, f => f.Lorem.Sentence()) - .RuleFor(x => x.Logo, f => f.Image.LoremFlickrUrl()) + .RuleFor(x => x.CoverImageId, f => f.Image.LoremFlickrUrl()) .RuleFor(x => x.Head, f => f.Person.FullName) .RuleFor(x => x.HeadDateOfBirth, f => f.Person.DateOfBirth) .RuleFor(x => x.ProviderTitle, f => f.Company.CompanyName()) From 5ef0c7aff0d72cd3f95a77b410af29590ec07181 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 7 Feb 2022 02:20:26 +0200 Subject: [PATCH 2/4] ElasticSearch sync --- .../OutOfSchool.ElasticsearchData/Models/WorkshopES.cs | 2 +- .../Extensions/MappingExtensionsTests.cs | 2 +- .../Extensions/ElasticsearchMappingExtensions.cs | 4 ++-- .../OutOfSchool.WebApi/Extensions/MappingExtensions.cs | 4 ++-- .../OutOfSchool.WebApi/Models/Workshop/WorkshopCard.cs | 2 +- OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OutOfSchool/OutOfSchool.ElasticsearchData/Models/WorkshopES.cs b/OutOfSchool/OutOfSchool.ElasticsearchData/Models/WorkshopES.cs index f23d3e6afe..621d179ca2 100644 --- a/OutOfSchool/OutOfSchool.ElasticsearchData/Models/WorkshopES.cs +++ b/OutOfSchool/OutOfSchool.ElasticsearchData/Models/WorkshopES.cs @@ -13,7 +13,7 @@ public class WorkshopES public string Title { get; set; } - public string Logo { get; set; } + public string CoverImageId { get; set; } public float Rating { get; set; } diff --git a/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs b/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs index 841d65082c..f58402ad2b 100644 --- a/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs +++ b/OutOfSchool/OutOfSchool.WebApi.Tests/Extensions/MappingExtensionsTests.cs @@ -325,7 +325,7 @@ public void Mapping_WorkshopDTO_ToCardDto_IsCorrect() Assert.AreEqual(workshopDto.ProviderTitle, result.ProviderTitle); Assert.AreEqual(workshopDto.MinAge, result.MinAge); Assert.AreEqual(workshopDto.MaxAge, result.MaxAge); - Assert.AreEqual(workshopDto.CoverImageId, result.Photo); + Assert.AreEqual(workshopDto.CoverImageId, result.CoverImageId); Assert.AreEqual(workshopDto.DirectionId, result.DirectionId); Assert.AreEqual(workshopDto.Address?.Id, result.Address.Id); Assert.IsNotNull(result.Address); diff --git a/OutOfSchool/OutOfSchool.WebApi/Extensions/ElasticsearchMappingExtensions.cs b/OutOfSchool/OutOfSchool.WebApi/Extensions/ElasticsearchMappingExtensions.cs index 2f5c593cbd..f91566794c 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Extensions/ElasticsearchMappingExtensions.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Extensions/ElasticsearchMappingExtensions.cs @@ -48,7 +48,7 @@ public static WorkshopCard ToCardDto(this WorkshopES workshopES) { cfg.CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.Logo)); + .ForMember(dest => dest.CoverImageId, opt => opt.MapFrom(s => s.CoverImageId)); cfg.CreateMap() .ForMember( dest => dest.Latitude, @@ -66,7 +66,7 @@ public static SearchResult ToSearchResult(this SearchResultES, SearchResult>(); cfg.CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.Logo)); + .ForMember(dest => dest.CoverImageId, opt => opt.MapFrom(s => s.CoverImageId)); cfg.CreateMap() .ForMember( dest => dest.Latitude, diff --git a/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs b/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs index 6e9e3ae19e..5d9106b74f 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Extensions/MappingExtensions.cs @@ -380,7 +380,7 @@ public static WorkshopCard ToCardDto(this WorkshopDTO workshopDTO) { cfg.CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.CoverImageId)); + .ForMember(dest => dest.CoverImageId, opt => opt.MapFrom(s => s.CoverImageId)); }); } @@ -391,7 +391,7 @@ public static WorkshopCard ToCard(this Workshop workshop) cfg.CreateMap(); cfg.CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.CoverImageId)) + .ForMember(dest => dest.CoverImageId, opt => opt.MapFrom(s => s.CoverImageId)) .ForMember(dest => dest.DirectionId, opt => opt.MapFrom(src => src.Direction.Id)); }); } diff --git a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCard.cs b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCard.cs index 18de89fe64..15369373f5 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCard.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Models/Workshop/WorkshopCard.cs @@ -26,7 +26,7 @@ public class WorkshopCard [Required] public bool IsPerMonth { get; set; } - public string Photo { get; set; } = string.Empty; + public string CoverImageId { get; set; } = string.Empty; [Required(ErrorMessage = "Children's min age is required")] [Range(0, 18, ErrorMessage = "Min age should be a number from 0 to 18")] diff --git a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs index ba13375794..85e8cba5a8 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Util/MappingProfile.cs @@ -105,7 +105,7 @@ public MappingProfile() .ForMember(dest => dest.Direction, opt => opt.Ignore()); CreateMap() .ForMember(dest => dest.WorkshopId, opt => opt.MapFrom(s => s.Id)) - .ForMember(dest => dest.Photo, opt => opt.MapFrom(s => s.CoverImageId)) + .ForMember(dest => dest.CoverImageId, opt => opt.MapFrom(s => s.CoverImageId)) .ForMember(dest => dest.DirectionId, opt => opt.MapFrom(src => src.Direction.Id)); CreateMap().ReverseMap() .ForMember(c => c.Parent, m => m.Ignore()); From 483b022aeb944b18e80b8590be24703cef2349e4 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 7 Feb 2022 15:14:42 +0200 Subject: [PATCH 3/4] Remove migration --- ...20205131231_WorkshopCoverImage.Designer.cs | 1465 ----------------- .../20220205131231_WorkshopCoverImage.cs | 23 - .../OutOfSchoolDbContextModelSnapshot.cs | 8 +- 3 files changed, 4 insertions(+), 1492 deletions(-) delete mode 100644 OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs delete mode 100644 OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs deleted file mode 100644 index 84d7c5a1af..0000000000 --- a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.Designer.cs +++ /dev/null @@ -1,1465 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using OutOfSchool.Services; - -namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations -{ - [DbContext(typeof(OutOfSchoolDbContext))] - [Migration("20220205131231_WorkshopCoverImage")] - partial class WorkshopCoverImage - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 64) - .HasAnnotation("ProductVersion", "5.0.11"); - - 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"); - }); - - 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"); - }); - - 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"); - }); - - 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"); - }); - - 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"); - }); - - 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"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("binary(16)"); - - b.Property("Title") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.HasKey("Id"); - - b.ToTable("AboutPortal"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortalItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("binary(16)"); - - b.Property("AboutPortalId") - .HasColumnType("binary(16)"); - - b.Property("Description") - .HasMaxLength(2000) - .HasColumnType("varchar(2000)"); - - b.Property("SectionName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("AboutPortalId"); - - b.ToTable("AboutPortalItems"); - }); - - 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("District") - .HasMaxLength(30) - .HasColumnType("varchar(30)"); - - 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.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("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.ChatWorkshop.ChatMessageWorkshop", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("binary(16)"); - - b.Property("ChatRoomId") - .HasColumnType("binary(16)"); - - b.Property("CreatedDateTime") - .HasColumnType("datetime(6)"); - - 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("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("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.Property("SocialGroupId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ParentId"); - - b.HasIndex("SocialGroupId"); - - b.ToTable("Children"); - }); - - 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("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("Title") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("varchar(60)"); - - b.HasKey("Id"); - - b.HasIndex("DepartmentId"); - - b.ToTable("Classes"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.DateTimeRange", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("EndTime") - .HasColumnType("time(6)"); - - 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("Title") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("varchar(60)"); - - 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("Title") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("varchar(60)"); - - 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("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("WorkshopImages"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.InstitutionStatus", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - 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 = "Має намір на реорганізацію" - }); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.Parent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("binary(16)"); - - 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("Description") - .IsRequired() - .HasMaxLength(500) - .IsUnicode(true) - .HasColumnType("varchar(500)"); - - 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("InstitutionStatusId") - .HasColumnType("bigint"); - - b.Property("LegalAddressId") - .HasColumnType("bigint"); - - 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") - .HasColumnType("tinyint(1)"); - - 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("InstitutionStatusId"); - - b.HasIndex("LegalAddressId"); - - b.HasIndex("UserId"); - - b.ToTable("Providers"); - }); - - 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("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("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.SupportInformation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("binary(16)"); - - b.Property("Description") - .HasMaxLength(3000) - .HasColumnType("varchar(3000)"); - - b.Property("SectionName") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Title") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.HasKey("Id"); - - b.ToTable("SupportInformation"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.Teacher", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("binary(16)"); - - b.Property("AvatarImageId") - .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("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("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(true); - - 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"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("binary(16)"); - - b.Property("AddressId") - .HasColumnType("bigint"); - - b.Property("ClassId") - .HasColumnType("bigint"); - - b.Property("CoverImageId") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("DepartmentId") - .HasColumnType("bigint"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("varchar(500)"); - - 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("Head") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("HeadDateOfBirth") - .HasColumnType("date"); - - b.Property("Instagram") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("IsPerMonth") - .HasColumnType("tinyint(1)"); - - b.Property("Keywords") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("MaxAge") - .HasColumnType("int"); - - b.Property("MinAge") - .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("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("ProviderId"); - - b.ToTable("Workshops"); - }); - - 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.AboutPortalItem", b => - { - b.HasOne("OutOfSchool.Services.Models.AboutPortal", "AboutPortal") - .WithMany("AboutPortalItems") - .HasForeignKey("AboutPortalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AboutPortal"); - }); - - 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.NoAction) - .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.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.HasOne("OutOfSchool.Services.Models.SocialGroup", "SocialGroup") - .WithMany("Children") - .HasForeignKey("SocialGroupId"); - - b.Navigation("Parent"); - - 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.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.Workshop", "Entity") - .WithMany("Images") - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Entity"); - }); - - 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.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("InstitutionStatus"); - - b.Navigation("LegalAddress"); - - b.Navigation("User"); - }); - - 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.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.NoAction) - .IsRequired(); - - b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") - .WithMany("Workshops") - .HasForeignKey("ProviderId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("Address"); - - b.Navigation("Class"); - - b.Navigation("Direction"); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortal", b => - { - b.Navigation("AboutPortalItems"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatRoomWorkshop", b => - { - b.Navigation("ChatMessages"); - }); - - 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("Workshops"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.SocialGroup", b => - { - b.Navigation("Children"); - }); - - modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => - { - b.Navigation("Applications"); - - b.Navigation("ChatRooms"); - - b.Navigation("DateTimeRanges"); - - b.Navigation("Images"); - - b.Navigation("Teachers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs deleted file mode 100644 index d7b0bba69c..0000000000 --- a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220205131231_WorkshopCoverImage.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations -{ - public partial class WorkshopCoverImage : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Logo", - table: "Workshops", - newName: "CoverImageId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "CoverImageId", - table: "Workshops", - newName: "Logo"); - } - } -} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs index 956a66f4f5..e1568c62fc 100644 --- a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs @@ -1010,10 +1010,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ClassId") .HasColumnType("bigint"); - b.Property("CoverImageId") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - b.Property("DepartmentId") .HasColumnType("bigint"); @@ -1057,6 +1053,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(200) .HasColumnType("varchar(200)"); + b.Property("Logo") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + b.Property("MaxAge") .HasColumnType("int"); From 8e5e1d1e784ca3b4d91222d977a4755d8f9be38a Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 7 Feb 2022 15:17:11 +0200 Subject: [PATCH 4/4] Add migration --- ...0207131559_WorkshopCoverImages.Designer.cs | 1465 +++++++++++++++++ .../20220207131559_WorkshopCoverImages.cs | 23 + .../OutOfSchoolDbContextModelSnapshot.cs | 8 +- 3 files changed, 1492 insertions(+), 4 deletions(-) create mode 100644 OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.Designer.cs create mode 100644 OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.cs diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.Designer.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.Designer.cs new file mode 100644 index 0000000000..2069b2ffec --- /dev/null +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.Designer.cs @@ -0,0 +1,1465 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using OutOfSchool.Services; + +namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations +{ + [DbContext(typeof(OutOfSchoolDbContext))] + [Migration("20220207131559_WorkshopCoverImages")] + partial class WorkshopCoverImages + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + 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"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("AboutPortal"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortalItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AboutPortalId") + .HasColumnType("binary(16)"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("SectionName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("AboutPortalId"); + + b.ToTable("AboutPortalItems"); + }); + + 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("District") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + 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.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("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.ChatWorkshop.ChatMessageWorkshop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("ChatRoomId") + .HasColumnType("binary(16)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + 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("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("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.Property("SocialGroupId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("SocialGroupId"); + + b.ToTable("Children"); + }); + + 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("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("Title") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.HasKey("Id"); + + b.HasIndex("DepartmentId"); + + b.ToTable("Classes"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.DateTimeRange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("EndTime") + .HasColumnType("time(6)"); + + 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("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("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("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("WorkshopImages"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.InstitutionStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + 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 = "Має намір на реорганізацію" + }); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Parent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + 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("Description") + .IsRequired() + .HasMaxLength(500) + .IsUnicode(true) + .HasColumnType("varchar(500)"); + + 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("InstitutionStatusId") + .HasColumnType("bigint"); + + b.Property("LegalAddressId") + .HasColumnType("bigint"); + + 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") + .HasColumnType("tinyint(1)"); + + 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("InstitutionStatusId"); + + b.HasIndex("LegalAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("Providers"); + }); + + 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("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("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.SupportInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("Description") + .HasMaxLength(3000) + .HasColumnType("varchar(3000)"); + + b.Property("SectionName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("SupportInformation"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Teacher", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AvatarImageId") + .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("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("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(true); + + 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"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("binary(16)"); + + b.Property("AddressId") + .HasColumnType("bigint"); + + b.Property("ClassId") + .HasColumnType("bigint"); + + b.Property("CoverImageId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DepartmentId") + .HasColumnType("bigint"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + 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("Head") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("HeadDateOfBirth") + .HasColumnType("date"); + + b.Property("Instagram") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("IsPerMonth") + .HasColumnType("tinyint(1)"); + + b.Property("Keywords") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("MaxAge") + .HasColumnType("int"); + + b.Property("MinAge") + .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("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("ProviderId"); + + b.ToTable("Workshops"); + }); + + 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.AboutPortalItem", b => + { + b.HasOne("OutOfSchool.Services.Models.AboutPortal", "AboutPortal") + .WithMany("AboutPortalItems") + .HasForeignKey("AboutPortalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AboutPortal"); + }); + + 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.NoAction) + .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.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.HasOne("OutOfSchool.Services.Models.SocialGroup", "SocialGroup") + .WithMany("Children") + .HasForeignKey("SocialGroupId"); + + b.Navigation("Parent"); + + 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.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.Workshop", "Entity") + .WithMany("Images") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Entity"); + }); + + 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.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("InstitutionStatus"); + + b.Navigation("LegalAddress"); + + b.Navigation("User"); + }); + + 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.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.NoAction) + .IsRequired(); + + b.HasOne("OutOfSchool.Services.Models.Provider", "Provider") + .WithMany("Workshops") + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Address"); + + b.Navigation("Class"); + + b.Navigation("Direction"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.AboutPortal", b => + { + b.Navigation("AboutPortalItems"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.ChatWorkshop.ChatRoomWorkshop", b => + { + b.Navigation("ChatMessages"); + }); + + 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("Workshops"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.SocialGroup", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("OutOfSchool.Services.Models.Workshop", b => + { + b.Navigation("Applications"); + + b.Navigation("ChatRooms"); + + b.Navigation("DateTimeRanges"); + + b.Navigation("Images"); + + b.Navigation("Teachers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.cs new file mode 100644 index 0000000000..6a8d6a9279 --- /dev/null +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/20220207131559_WorkshopCoverImages.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace OutOfSchool.IdentityServer.Data.Migrations.OutOfSchoolMigrations +{ + public partial class WorkshopCoverImages : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Logo", + table: "Workshops", + newName: "CoverImageId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "CoverImageId", + table: "Workshops", + newName: "Logo"); + } + } +} diff --git a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs index e1568c62fc..956a66f4f5 100644 --- a/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs +++ b/OutOfSchool/OutOfSchool.IdentityServer/Data/Migrations/OutOfSchoolMigrations/OutOfSchoolDbContextModelSnapshot.cs @@ -1010,6 +1010,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ClassId") .HasColumnType("bigint"); + b.Property("CoverImageId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + b.Property("DepartmentId") .HasColumnType("bigint"); @@ -1053,10 +1057,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(200) .HasColumnType("varchar(200)"); - b.Property("Logo") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - b.Property("MaxAge") .HasColumnType("int");