Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft workshop management #1602

Merged
merged 19 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cf4a830
Added model WorkshopDraft
IrynaNakoneshniuk Oct 30, 2024
edd2f8a
Added WorkshopDraftRepository, DTO, and a NuGet package for handling …
IrynaNakoneshniuk Nov 15, 2024
208bf31
Resolved conflict
IrynaNakoneshniuk Nov 15, 2024
333977a
Added Pomelo.EntityFrameworkCore.MySql.Json.Microsoft
IrynaNakoneshniuk Nov 15, 2024
1fc8969
Added WorkshopDraftService and fixed a mapping issue in tests related…
IrynaNakoneshniuk Nov 21, 2024
f0c3997
Fixed DTOs model, processing of adding new images associated with the…
IrynaNakoneshniuk Nov 23, 2024
51620e6
Add AttributeUsage and improve Create method with concurrency settings
IrynaNakoneshniuk Dec 1, 2024
3d2df03
Added validation for proper completion of parallel tasks.
IrynaNakoneshniuk Dec 1, 2024
1322658
Resolved conflict
IrynaNakoneshniuk Dec 8, 2024
7c0d8fd
Change WorkshopDraft Model
AndriyYehorov Jan 2, 2025
d0d1e6d
Change create and Add other draft operations in WorkshopDraftService …
AndriyYehorov Jan 2, 2025
de84e41
Fix double deletion in WorkshopService
AndriyYehorov Jan 2, 2025
71eb7f7
Add tests for WorkshopDraftService and Controller
AndriyYehorov Jan 2, 2025
7beb0f0
Add TrackableEntityInterceptorTests
AndriyYehorov Jan 5, 2025
e16475c
Add more tests for WorkshopDraftService, Controller, Repository
AndriyYehorov Jan 5, 2025
9f858a8
Change DateTimeRangeDraft and DateTimeRangeDraftDto
AndriyYehorov Jan 7, 2025
83f6a8a
Change OutOfSchoolDbContext to TestOutOfSchoolDbContext in some tests
AndriyYehorov Jan 10, 2025
671884e
Fix comments + remove unused WorkshopDraftCreateDto
AndriyYehorov Jan 15, 2025
46339fe
Add migrations.
AndriyYehorov Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OutOfSchool/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<PackageVersion Include="OpenIddict.Quartz" Version="$(OpenIdDictVersion)" />
<PackageVersion Include="OpenIddict.Validation.AspNetCore" Version="$(OpenIdDictVersion)" />
<PackageVersion Include="OpenIddict.Validation.SystemNetHttp" Version="$(OpenIdDictVersion)" />
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql.Json.Microsoft" Version="8.0.0" />
<!--Serilog-->
<PackageVersion Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageVersion Include="Serilog.Enrichers.GlobalLogContext" Version="1.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using OutOfSchool.EmailSender.Services;
using Microsoft.Extensions.Options;
using OutOfSchool.AuthCommon.Config;
using OutOfSchool.Tests.Common.DbContextTests;

namespace OutOfSchool.AuthServer.Tests.Controllers;

Expand Down Expand Up @@ -272,9 +273,9 @@ private async Task SeedAreaAdmin(AreaAdmin areaAdmin)
await context.SaveChangesAsync();
}

private static OutOfSchoolDbContext GetContext()
private static TestOutOfSchoolDbContext GetContext()
{
return new OutOfSchoolDbContext(
return new TestOutOfSchoolDbContext(
new DbContextOptionsBuilder<OutOfSchoolDbContext>()
.UseInMemoryDatabase(databaseName: "OutOfSchoolTestDB")
.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using OutOfSchool.EmailSender.Services;
using Microsoft.Extensions.Options;
using OutOfSchool.AuthCommon.Config;
using OutOfSchool.Tests.Common.DbContextTests;

namespace OutOfSchool.AuthServer.Tests.Controllers;

Expand Down Expand Up @@ -221,9 +222,9 @@ private async Task SeedMinistryAdmin(InstitutionAdmin ministryAdmin)
await context.SaveChangesAsync();
}

private static OutOfSchoolDbContext GetContext()
private static TestOutOfSchoolDbContext GetContext()
{
return new OutOfSchoolDbContext(
return new TestOutOfSchoolDbContext(
new DbContextOptionsBuilder<OutOfSchoolDbContext>()
.UseInMemoryDatabase(databaseName: "OutOfSchoolTestDB")
.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using OutOfSchool.EmailSender.Services;
using Microsoft.Extensions.Options;
using OutOfSchool.AuthCommon.Config;
using OutOfSchool.Tests.Common.DbContextTests;

namespace OutOfSchool.AuthServer.Tests.Controllers;

Expand Down Expand Up @@ -272,9 +273,9 @@ private async Task SeedRegionAdmin(RegionAdmin regionAdmin)
await context.SaveChangesAsync();
}

private static OutOfSchoolDbContext GetContext()
private static TestOutOfSchoolDbContext GetContext()
{
return new OutOfSchoolDbContext(
return new TestOutOfSchoolDbContext(
new DbContextOptionsBuilder<OutOfSchoolDbContext>()
.UseInMemoryDatabase(databaseName: "OutOfSchoolTestDB")
.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using OutOfSchool.Services.Enums;
using OutOfSchool.Services.Models;
using OutOfSchool.Services.Repository;
using OutOfSchool.Tests.Common.DbContextTests;
using OutOfSchool.Tests.Common.TestDataGenerators;
using System;
using System.Net;
Expand Down Expand Up @@ -163,9 +164,9 @@ public async Task Update_WhenAllValid_ReturnsOkResponse()
Assert.AreEqual(HttpStatusCode.OK, result.HttpStatusCode);
}

private static OutOfSchoolDbContext GetContext()
private static TestOutOfSchoolDbContext GetContext()
{
return new OutOfSchoolDbContext(
return new TestOutOfSchoolDbContext(
new DbContextOptionsBuilder<OutOfSchoolDbContext>()
.UseInMemoryDatabase(databaseName: "OutOfSchoolTestDB")
.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using OutOfSchool.Services;
using OutOfSchool.Services.Models;
using OutOfSchool.Services.Repository;
using OutOfSchool.Tests.Common.DbContextTests;
using OutOfSchool.Tests.Common.TestDataGenerators;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -185,9 +186,9 @@ public void HostsConfig_WhenValueNull_ThrowsException()
mockHostsConfig.Object));
}

private static OutOfSchoolDbContext GetContext()
private static TestOutOfSchoolDbContext GetContext()
{
return new OutOfSchoolDbContext(
return new TestOutOfSchoolDbContext(
new DbContextOptionsBuilder<OutOfSchoolDbContext>()
.UseInMemoryDatabase(databaseName: "OutOfSchoolTestDB")
.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning))
Expand Down
1 change: 1 addition & 0 deletions OutOfSchool/OutOfSchool.AuthorizationServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ await services.AddDefaultQuartz(
serverVersion,
optionsBuilder =>
optionsBuilder
.UseMicrosoftJson()
.EnableRetryOnFailure(3, TimeSpan.FromSeconds(5), null)
.MigrationsAssembly(migrationsAssembly)))
.AddDbContext<OpenIdDictDbContext>(options => options
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace OutOfSchool.BusinessLogic.Config.Images;
public class UploadConcurrencySettings
{
/// <summary>
/// The maximum number of concurrent image uploads allowed.
/// Adjust this value to balance performance and resource usage.
/// </summary>
public int MaxParallelImageUploads { get; set; } = 4;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft.AddressDraft;
public class AddressDraftDto
{
[Required(ErrorMessage = "Street is required")]
[MaxLength(200)]
public string Street { get; set; } = string.Empty;

[Required(ErrorMessage = "Building number is required")]
[MaxLength(15)]
public string BuildingNumber { get; set; } = string.Empty;

[Range(-90, 90, ErrorMessage = "Latitude must be between -90 and 90 degrees")]
public double Latitude { get; set; }

[Range(-180, 180, ErrorMessage = "Longitude must be between -180 and 180 degrees")]
public double Longitude { get; set; }

[Required(ErrorMessage = "CATOTTGId is required")]
public long CATOTTGId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
using OutOfSchool.Services.Enums;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft;

public class DateTimeRangeDraftDto
{
public TimeOnly StartTime { get; set; }

public TimeOnly EndTime { get; set; }

[Required]
public HashSet<DaysBitMask> Workdays { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using OutOfSchool.BusinessLogic.Common;
using OutOfSchool.BusinessLogic.Models.WorkshopDraft.TeacherDrafts;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft.TeacherDraft;
/// <summary>
/// Represents the result of a teacher creation or update operation,
/// including details about the teacher and the result of the cover image upload.
/// </summary>
public class TeacherCreateUpdateResultDto
{
/// <summary>
/// Contains the details of the created or updated teacher.
/// </summary>
public TeacherDraftResponseDto Teacher { get; set; }

/// <summary>
/// Represents the result of the operation to upload the teacher's cover image,
/// including success or failure information.
/// </summary>
public OperationResult UploadingCoverImageResult { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Newtonsoft.Json;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft.TeacherDrafts;
public class TeacherDraftCreateDto : TeacherDraftDto
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public IFormFile CoverImage { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Newtonsoft.Json;
using OutOfSchool.Common.Validators;
using OutOfSchool.Services.Enums;
using System.ComponentModel.DataAnnotations;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft.TeacherDrafts;

public class TeacherDraftDto
{
[Required(ErrorMessage = Constants.RequiredFirstNameErrorMessage)]
[DataType(DataType.Text)]
[MaxLength(Constants.NameMaxLength)]
[CustomUkrainianName(ErrorMessage = Constants.InvalidFirstNameErrorMessage)]
public string FirstName { get; set; }

[Required(ErrorMessage = Constants.RequiredLastNameErrorMessage)]
[DataType(DataType.Text)]
[MaxLength(Constants.NameMaxLength)]
[CustomUkrainianName(ErrorMessage = Constants.InvalidLastNameErrorMessage)]
public string LastName { get; set; }

[DataType(DataType.Text)]
[MaxLength(Constants.NameMaxLength)]
[CustomUkrainianName(ErrorMessage = Constants.InvalidMiddleNameErrorMessage)]
public string MiddleName { get; set; }

[Required(ErrorMessage = "Gender is required")]
[EnumDataType(typeof(Gender), ErrorMessage = Constants.EnumErrorMessage)]
public Gender Gender { get; set; }

[Required(ErrorMessage = "Date of birth is required")]
[DataType(DataType.Date)]
public DateTime DateOfBirth { get; set; }

[DataType(DataType.Text)]
[MaxLength(Constants.TeacherDescriptionLength)]
public string Description { get; set; }

[Required]
public bool IsDefaultTeacher { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft.TeacherDrafts;
public class TeacherDraftResponseDto : TeacherDraftDto
{
public Guid Id { get; set; }

public Guid WorkshopDraftId { get; set; }

public string CoverImageId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using OutOfSchool.BusinessLogic.Common;
using OutOfSchool.BusinessLogic.Models.Images;
using OutOfSchool.BusinessLogic.Models.WorkshopDraft.TeacherDraft;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft;
/// <summary>
/// Represents the result of uploading workshop and teacher images.
/// </summary>
public class UploadImagesResult
{
/// <summary>
/// Results of uploading images for teachers.
/// </summary>
public List<TeacherCreateUpdateResultDto> TeacherImagesUploadingResults { get; set; }

/// <summary>
/// Results of uploading workshop images.
/// </summary>
public MultipleImageUploadingResult WorkshopImagesUploadingResult { get; set; }

/// <summary>
/// Result of uploading the workshop cover image.
/// </summary>
public OperationResult WorkshopCoverImageUploadingResult { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft;

public class WorkshopDescriptionItemDraftDto
{
[Required]
[MaxLength(Constants.WorkshopDraftDescriptionItemsLength)]
public string SectionName { get; set; }

[Required]
[MaxLength(Constants.WorkshopDraftDescriptionItemsLength)]
public string Description { get; set; }
}
Loading
Loading