Add project
All checks were successful
SanStudent Multi-Project Deployment / deploy-api (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontadmin (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontstudent (push) Successful in 40s

This commit is contained in:
aherman-san
2026-03-07 11:14:26 +01:00
parent bca807d4c1
commit b8f03bf6d3
191 changed files with 122377 additions and 0 deletions

18
Common/Common.csproj Normal file
View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Requests\**" />
<Compile Remove="Responses\**" />
<EmbeddedResource Remove="Requests\**" />
<EmbeddedResource Remove="Responses\**" />
<None Remove="Requests\**" />
<None Remove="Responses\**" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
using System.Net;
namespace Common.Dtos.Common;
public abstract class BaseResponse
{
public bool Ok { get; set; }
public string? Error { get; set; }
}

View File

@@ -0,0 +1,22 @@
namespace Common.Dtos.Common;
public class PagedList<T>
{
public PagedList(T[] items, int pageNumber, int pageSize, int totalItemsCount, int numberOfPages)
{
Items = items;
PageNumber = pageNumber;
PageSize = pageSize;
TotalItemsCount = totalItemsCount;
NumberOfPages = numberOfPages;
}
public static PagedList<T> Empty(int pagedNumber, int pageSize)
=> new([], pagedNumber, pageSize, 0, 0);
public T[] Items { get; }
public int PageNumber { get; }
public int PageSize { get; }
public int TotalItemsCount { get; }
public int NumberOfPages { get; }
}

View File

@@ -0,0 +1,7 @@
namespace Common.Dtos.Common;
public abstract class PagedRequest
{
public int PageNumber { get; set; }
public int PageSize { get; set; }
}

View File

@@ -0,0 +1,11 @@
namespace Common.Dtos.Common;
public class ValidationProblems
{
public ValidationProblems()
{
Errors = [];
}
public List<string> Errors { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace Common.Dtos.Season;
public class CreateSeasonRequest
{
public string? Name { get; set; }
public DateOnly StartDate { get; set; }
public DateOnly EndDate { get; set; }
}

View File

@@ -0,0 +1,8 @@
using Common.Dtos.Common;
namespace Common.Dtos.Season;
public class CreateSeasonResponse : BaseResponse
{
public string? CreateSeasonResult { get; set; }
}

View File

@@ -0,0 +1,9 @@
using Common.Dtos.Common;
namespace Common.Dtos.Season;
public class GetSeasonsRequest : PagedRequest
{
public string? Name { get; set; }
public bool? HideObsolete { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace Common.Dtos.Season;
public class SeasonDto
{
public int Id { get; set; }
public string? Name { get; set; }
public DateOnly StartDate { get; set; }
public DateOnly EndDate { get; set; }
public bool IsCurrent => StartDate <= DateOnly.FromDateTime(DateTime.Now) && EndDate >= DateOnly.FromDateTime(DateTime.Now);
}

View File

@@ -0,0 +1,7 @@
namespace Common.Dtos.Specialization;
public class CreateSpecializationRequest
{
public string? Name { get; set; }
public string? ShortName { get; set; }
}

View File

@@ -0,0 +1,12 @@
using Common.Dtos.Common;
using System;
using System.Collections.Generic;
using System.Text;
namespace Common.Dtos.Specialization
{
public class CreateSpecializationResponse : BaseResponse
{
public string? CreateSpecializationResult { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
using Common.Dtos.Common;
namespace Common.Dtos.Specialization;
public class GetSpecializationsRequest : PagedRequest
{
public string? Name { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace Common.Dtos.Specialization;
public class SpecializationDto
{
public int Id { get; set; }
public string? Name { get; set; }
public string? ShortName { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace Common.Dtos.Student;
public class CreateStudentRequest
{
public required string FirstName { get; set; }
public required string LastName { get; set; }
public required string AlbumNumber { get; set; }
}

View File

@@ -0,0 +1,8 @@
using Common.Dtos.Common;
namespace Common.Dtos.Student;
public class CreateStudentResponse : BaseResponse
{
public string? CreateStudentResult { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace Common.Dtos.Student;
public class StudentBasicDto
{
public Guid Id { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? AlbumNumber { get; set; }
public string FullNameReverese => $"{LastName} {FirstName} ({AlbumNumber})";
}

View File

@@ -0,0 +1,7 @@
namespace Common.Dtos.Subject;
public class CreateSubjectRequest
{
public string? Name { get; set; }
public string? ShortName { get; set; }
}

View File

@@ -0,0 +1,12 @@
using Common.Dtos.Common;
using System;
using System.Collections.Generic;
using System.Text;
namespace Common.Dtos.Subject
{
public class CreateSubjectResponse : BaseResponse
{
public string? CreateSubjectResult { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
using Common.Dtos.Common;
namespace Common.Dtos.Subject;
public class GetSubjectsRequest : PagedRequest
{
public string? Name { get; set; }
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Common.Dtos.Subject;
public class SubjectDto
{
public int Id { get; set; }
public string? Name { get; set; }
public string? ShortName { get; set; }
}

View File

@@ -0,0 +1,11 @@
using System.Text.Json;
namespace Common.Extensions
{
public static class JsonExtensions
{
private static JsonSerializerOptions _jso = new() { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
public static string ToJson<T>(this T source) => JsonSerializer.Serialize(source, _jso);
public static T FromJson<T>(this string source) => JsonSerializer.Deserialize<T>(source, _jso) ?? default!;
}
}

View File

@@ -0,0 +1,20 @@
using Common.Pagination;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Common.Extensions;
public static class StringExtensions
{
public static IDictionary<string, object?> AsDictionary(this object source,
BindingFlags bindingAttr = BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance)
{
return source.GetType().GetProperties(bindingAttr).ToDictionary
(
propInfo => propInfo.Name,
propInfo => propInfo.GetValue(source, null)
);
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Common.Pagination;
public static class PaginationExtensions
{
public static string ToPaginationSummary(this PaginationProperties props)
{
var before = (props.PageSize * (props.PageNumber - 1)) + 1;
var after = Math.Min((props.PageSize * props.PageNumber), props.TotalItems);
return props.TotalItems == 0 ? $"{props.Text}: brak" : $"{props.Text}: {before}-{after} z {props.TotalItems}";
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Common.Pagination;
public class PaginationProperties
{
public PaginationProperties(string text, int pageSize)
{
Text = text;
PageNumber = 1;
PageSize = pageSize;
}
public int PageNumber { get; set; }
public int PageSize { get; set; }
public int TotalItems { get; set; }
public int NumberOfPages { get; set; }
public string? Text { get; set; }
}