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

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions OutOfSchool/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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,18 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using OutOfSchool.BusinessLogic.Util.JsonTools;
using OutOfSchool.Services.Enums;

namespace OutOfSchool.BusinessLogic.Models.WorkshopDraft;

public class DateTimeRangeDraftDto
{
[JsonConverter(typeof(TimespanConverter))]
public TimeSpan StartTime { get; set; }

[JsonConverter(typeof(TimespanConverter))]
public TimeSpan EndTime { get; set; }

[Required]
public List<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