From 177b6a78355f783e07cccf66dad97454f54dc439 Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sat, 13 Apr 2024 15:12:08 +0200 Subject: [PATCH 001/319] Test --- _ | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 _ diff --git a/_ b/_ new file mode 100644 index 000000000..e69de29bb From 5ac3d5e7ada069752facb0927c29ea38d621d56c Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sat, 13 Apr 2024 15:17:15 +0200 Subject: [PATCH 002/319] Test completed --- _ | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 _ diff --git a/_ b/_ deleted file mode 100644 index e69de29bb..000000000 From 57ac36c7ecdc3545e227ef028f1cbba8cbe54c99 Mon Sep 17 00:00:00 2001 From: eggwhat Date: Sat, 20 Apr 2024 19:47:03 +0200 Subject: [PATCH 003/319] (#57) add name and email fields for identity service --- .../MiniSpace.Web/Areas/Identity/IdentityService.cs | 13 +++++++++++++ .../src/MiniSpace.Web/MiniSpace.Web.csproj | 1 + 2 files changed, 14 insertions(+) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs index 0396c3e11..c1507de43 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; using System.Threading.Tasks; using MiniSpace.Web.DTO; using MiniSpace.Web.HttpClients; @@ -8,12 +9,16 @@ namespace MiniSpace.Web.Areas.Identity class IdentityService : IIdentityService { private readonly IHttpClient _httpClient; + private readonly JwtSecurityTokenHandler _jwtHandler; public JwtDto JwtDto { get; private set; } + public string Name {get; private set; } + public string Email {get; private set; } public bool IsAuthenticated { get; private set; } public IdentityService(IHttpClient httpClient) { _httpClient = httpClient; + _jwtHandler = new JwtSecurityTokenHandler(); } public Task GetAccountAsync() @@ -28,13 +33,21 @@ public Task SignUpAsync(string firstName, string lastName, string email, string public async Task SignInAsync(string email, string password) { JwtDto = await _httpClient.PostAsync("identity/sign-in", new {email, password}); + + var jwtToken = _jwtHandler.ReadJwtToken(JwtDto.AccessToken); + var payload = jwtToken.Payload; + Name = (string)payload["name"]; + Email = (string)payload["e-mail"]; IsAuthenticated = true; + return JwtDto; } public void Logout() { JwtDto = null; + Name = null; + Email = null; IsAuthenticated = false; } } diff --git a/MiniSpace.Web/src/MiniSpace.Web/MiniSpace.Web.csproj b/MiniSpace.Web/src/MiniSpace.Web/MiniSpace.Web.csproj index 1636d5826..c2ae8bcd0 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/MiniSpace.Web.csproj +++ b/MiniSpace.Web/src/MiniSpace.Web/MiniSpace.Web.csproj @@ -15,6 +15,7 @@ + From 179757991818aa57118becae189d0fb1b9fcba41 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Sat, 20 Apr 2024 22:22:55 +0200 Subject: [PATCH 004/319] (#57) add page for creating new event --- .../Areas/Events/EventsService.cs | 4 +- .../Areas/Events/IEventsService.cs | 4 +- .../Models/Events/AddEventModel.cs | 24 +++ .../src/MiniSpace.Web/Pages/CreateEvent.razor | 151 ++++++++++++++++++ .../src/MiniSpace.Web/Pages/Events.razor | 40 +++++ .../src/MiniSpace.Web/Shared/MainLayout.razor | 2 + 6 files changed, 221 insertions(+), 4 deletions(-) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Models/Events/AddEventModel.cs create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/CreateEvent.razor create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs index 3b3dbde48..59036c0fd 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs @@ -31,9 +31,9 @@ public Task>> GetStudentEventsAsync(Guid return _httpClient.GetAsync>>($"events/student/{studentId}"); } - public Task AddEventAsync(Guid eventId, string name, Guid organizerId, DateTime startDate, DateTime endDate, + public Task AddEventAsync(Guid eventId, string name, Guid organizerId, string startDate, string endDate, string buildingName, string street, string buildingNumber, string apartmentNumber, string city, string zipCode, - string description, int capacity, decimal fee, string category, DateTime publishDate) + string description, int capacity, decimal fee, string category, string publishDate) { _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); return _httpClient.PostAsync("events", new {eventId, name, organizerId, startDate, endDate, buildingName, diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs index 6108fbe72..f3ceb9d40 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs @@ -11,9 +11,9 @@ public interface IEventsService { Task GetEventAsync(Guid eventId); Task>> GetStudentEventsAsync(Guid studentId, int numberOfResults); - Task AddEventAsync(Guid eventId, string name, Guid organizerId, DateTime startDate, DateTime endDate, + Task AddEventAsync(Guid eventId, string name, Guid organizerId, string startDate, string endDate, string buildingName, string street, string buildingNumber, string apartmentNumber, string city, - string zipCode, string description, int capacity, decimal fee, string category, DateTime publishDate); + string zipCode, string description, int capacity, decimal fee, string category, string publishDate); Task SignUpToEventAsync(Guid eventId, Guid studentId); Task ShowInterestInEventAsync(Guid eventId, Guid studentId); Task RateEventAsync(Guid eventId, int rating, Guid studentId); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Models/Events/AddEventModel.cs b/MiniSpace.Web/src/MiniSpace.Web/Models/Events/AddEventModel.cs new file mode 100644 index 000000000..45c5a5fa6 --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Models/Events/AddEventModel.cs @@ -0,0 +1,24 @@ +using System; + +namespace MiniSpace.Web.Models.Events +{ + public class AddEventModel + { + public Guid EventId { get; set; } + public string Name { get; set; } + public Guid OrganizerId { get; set; } + public DateTime StartDate { get; set; } + public DateTime EndDate { get; set; } + public string BuildingName { get; set; } + public string Street { get; set; } + public string BuildingNumber { get; set; } + public string ApartmentNumber { get; set; } + public string City { get; set; } + public string ZipCode { get; set; } + public string Description { get; set; } + public int Capacity { get; set; } + public decimal Fee { get; set; } + public string Category { get; set; } + public DateTime? PublishDate { get; set; } + } +} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/CreateEvent.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/CreateEvent.razor new file mode 100644 index 000000000..5cbf862ae --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/CreateEvent.razor @@ -0,0 +1,151 @@ +@page "/events/create" +@using MiniSpace.Web.Areas.Identity +@using MiniSpace.Web.Areas.Events +@using MiniSpace.Web.DTO +@using MiniSpace.Web.Models.Events +@using Radzen +@inject IIdentityService IdentityService +@inject IEventsService EventsService +@inject NavigationManager NavigationManager + +

Create new event

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @if (publishInfo == 2) + { + + } + + + + + + + + + + + + + + + +@code { + private UserDto userDto = new(); + + private AddEventModel addEventModel = new() + { + Name = "One of first events!", + Category = "Art", + StartDate = new DateTime(2024, 04, 25), + EndDate = new DateTime(2024, 04, 27), + BuildingName = "Gmach Główny", + Street = "Plac Politechniki", + BuildingNumber = "1", + ApartmentNumber = "1", + City = "Warszawa", + ZipCode = "00-061", + Description = "Great event!", + Capacity = 30, + Fee = 34.44M + }; + private bool showError = false; + private bool popup; + private int publishInfo = 1; + + private List categories = + [ + "Music", + "Sports", + "Education", + "Science", + "Technology", + "Art", + "Business", + "Health", + "Charity", + "Other" + ]; + + protected override async Task OnInitializedAsync() + { + if (IdentityService.IsAuthenticated) + { + userDto = await IdentityService.GetAccountAsync(); + } + } + + private async Task HandleCreateEvent() + { + addEventModel.OrganizerId = userDto.Id; + if (publishInfo == 1) + { + addEventModel.PublishDate = null; + } + + await EventsService.AddEventAsync(Guid.Empty, addEventModel.Name, addEventModel.OrganizerId, + addEventModel.StartDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + addEventModel.EndDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + addEventModel.BuildingName, addEventModel.Street, addEventModel.BuildingNumber, + addEventModel.ApartmentNumber, addEventModel.City, addEventModel.ZipCode, + addEventModel.Description, addEventModel.Capacity, addEventModel.Fee, addEventModel.Category, + addEventModel.PublishDate?.ToString("yyyy-MM-ddTHH:mm:ss.fffZ")); + NavigationManager.NavigateTo("/events"); + } +} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor new file mode 100644 index 000000000..ccec11cc7 --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor @@ -0,0 +1,40 @@ +@page "/events" +@using MiniSpace.Web.Areas.Students +@using MiniSpace.Web.DTO +@using Radzen +@inject IIdentityService IdentityService +@inject IStudentsService StudentsService +@inject NavigationManager NavigationManager + +

Events

+ +@if (studentDto.Id != Guid.Empty) +{ + + + + + + + + + +} +else +{ +

Loading...

+} + +@code { + private StudentDto studentDto = new(); + + protected override async Task OnInitializedAsync() + { + if (IdentityService.IsAuthenticated) + { + var userDto = await IdentityService.GetAccountAsync(); + studentDto = await StudentsService.GetStudentAsync(userDto.Id); + } + } +} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor b/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor index 232330fa4..43b76d2da 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor @@ -44,6 +44,8 @@ Click="@(() => NavigationManager.NavigateTo(""))" /> + } From 4eca65c94aa8b30267d868ccb9c2add1f1c83e28 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Sun, 21 Apr 2024 01:08:26 +0200 Subject: [PATCH 005/319] (#57) add structure of page for searching events --- .../Areas/Events/EventsService.cs | 3 +- .../Areas/Events/IEventsService.cs | 2 +- .../MiniSpace.Web/Data/Events/SearchEvents.cs | 6 +- .../{CreateEvent.razor => EventCreate.razor} | 0 .../src/MiniSpace.Web/Pages/Events.razor | 2 + .../MiniSpace.Web/Pages/EventsSearch.razor | 77 +++++++++++++++++++ 6 files changed, 85 insertions(+), 5 deletions(-) rename MiniSpace.Web/src/MiniSpace.Web/Pages/{CreateEvent.razor => EventCreate.razor} (100%) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs index 59036c0fd..5120de54e 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs @@ -58,7 +58,8 @@ public Task RateEventAsync(Guid eventId, int rating, Guid studentId) return _httpClient.PostAsync($"events/{eventId}/rate", new {eventId, rating, studentId}); } - public Task>> SearchEventsAsync(string name, string organizer, DateTime dateFrom, DateTime dateTo, PageableDto pageable) + public Task>> SearchEventsAsync(string name, string organizer, + string dateFrom, string dateTo, PageableDto pageable) { return _httpClient.PostAsync>>("events/search", new (name, organizer, dateFrom, dateTo, pageable)); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs index f3ceb9d40..caccb25c4 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs @@ -18,6 +18,6 @@ Task AddEventAsync(Guid eventId, string name, Guid organizerId, string startDate Task ShowInterestInEventAsync(Guid eventId, Guid studentId); Task RateEventAsync(Guid eventId, int rating, Guid studentId); Task>> SearchEventsAsync(string name, string organizer, - DateTime dateFrom, DateTime dateTo, PageableDto pageable); + string dateFrom, string dateTo, PageableDto pageable); } } \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Data/Events/SearchEvents.cs b/MiniSpace.Web/src/MiniSpace.Web/Data/Events/SearchEvents.cs index b8e8c7780..530410010 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Data/Events/SearchEvents.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Data/Events/SearchEvents.cs @@ -7,11 +7,11 @@ public class SearchEvents { public string Name { get; set; } public string Organizer { get; set; } - public DateTime DateFrom { get; set; } - public DateTime DateTo { get; set; } + public string DateFrom { get; set; } + public string DateTo { get; set; } public PageableDto Pageable { get; set; } - public SearchEvents(string name, string organizer, DateTime dateFrom, DateTime dateTo, PageableDto pageable) + public SearchEvents(string name, string organizer, string dateFrom, string dateTo, PageableDto pageable) { Name = name; Organizer = organizer; diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/CreateEvent.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/EventCreate.razor similarity index 100% rename from MiniSpace.Web/src/MiniSpace.Web/Pages/CreateEvent.razor rename to MiniSpace.Web/src/MiniSpace.Web/Pages/EventCreate.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor index ccec11cc7..95d58ae5e 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events.razor @@ -16,6 +16,8 @@ + diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor new file mode 100644 index 000000000..5557fd7d3 --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor @@ -0,0 +1,77 @@ +@page "/events/search" +@using MiniSpace.Web.Areas.Identity +@using MiniSpace.Web.Areas.Events +@using MiniSpace.Web.DTO +@using MiniSpace.Web.DTO.Wrappers +@using MiniSpace.Web.Models.Events +@using Radzen +@inject IIdentityService IdentityService +@inject IEventsService EventsService +@inject NavigationManager NavigationManager + +

Search events

+ + + + + + + +@code { + private bool showError = false; + private bool popup; + private int publishInfo = 1; + + string pagingSummaryFormat = "Displaying page {0} of {1} (total {2} records)"; + int pageSize = 2; + int count = 12; + IEnumerable events; + IEnumerable eventPages; + + protected override async Task OnInitializedAsync() + { + var tmp = await EventsService.SearchEventsAsync("event", "", + new DateTime(2024, 04, 10).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + new DateTime(2024, 04, 30).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + new PageableDto() + { + Page = 1, + Size = 6, + Sort = new SortDto() + { + SortBy = new List(){"description"}, + Direction = "Ascending" + } + }); + events = tmp.Content; + } + + void PageChanged(PagerEventArgs args) + { + //events = GetEvents(args.Skip, args.Top); + } +} From 24fa838c60d42b323ae0eb7ba3342462bad9bf2a Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Sun, 21 Apr 2024 01:38:32 +0200 Subject: [PATCH 006/319] (#57) add paging for searching events --- .../Models/Events/SearchEventsModel.cs | 13 +++++ .../MiniSpace.Web/Pages/EventsSearch.razor | 51 ++++++++++++------- 2 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs diff --git a/MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs b/MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs new file mode 100644 index 000000000..39a814b42 --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs @@ -0,0 +1,13 @@ +using MiniSpace.Web.DTO.Wrappers; + +namespace MiniSpace.Web.Models.Events +{ + public class SearchEventModel + { + public string Name { get; set; } + public string Organizer { get; set; } + public string DateFrom { get; set; } + public string DateTo { get; set; } + public PageableDto Pageable { get; set; } + } +} \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor index 5557fd7d3..b68cc7e1c 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor @@ -39,39 +39,52 @@ - + @code { + + private SearchEventModel searchEventModel = new() + { + Name = "", + Organizer = "", + DateFrom = "", + DateTo = "", + Pageable = new PageableDto() + { + Page = 1, + Size = 6, + Sort = new SortDto() + { + SortBy = new List() { "dateFrom" }, + Direction = "Ascending" + } + } + }; + private bool showError = false; private bool popup; private int publishInfo = 1; string pagingSummaryFormat = "Displaying page {0} of {1} (total {2} records)"; - int pageSize = 2; - int count = 12; + int count = 0; IEnumerable events; - IEnumerable eventPages; + protected override async Task OnInitializedAsync() { - var tmp = await EventsService.SearchEventsAsync("event", "", - new DateTime(2024, 04, 10).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - new DateTime(2024, 04, 30).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - new PageableDto() - { - Page = 1, - Size = 6, - Sort = new SortDto() - { - SortBy = new List(){"description"}, - Direction = "Ascending" - } - }); + var tmp = await EventsService.SearchEventsAsync(searchEventModel.Name, searchEventModel.Organizer, + searchEventModel.DateFrom, searchEventModel.DateTo, searchEventModel.Pageable); + count = tmp.TotalElements; events = tmp.Content; } - void PageChanged(PagerEventArgs args) + private async void PageChanged(PagerEventArgs args) { - //events = GetEvents(args.Skip, args.Top); + searchEventModel.Pageable.Page = args.PageIndex + 1; + + var tmp = await EventsService.SearchEventsAsync(searchEventModel.Name, searchEventModel.Organizer, + searchEventModel.DateFrom, searchEventModel.DateTo, searchEventModel.Pageable); + events = tmp.Content; } } From 5d352f503ce2b5b53241b1b33eb2c16230b97962 Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sun, 21 Apr 2024 09:19:05 +0200 Subject: [PATCH 007/319] (#48) Add project structure --- MiniSpace.Services.Reactions/.gitignore | 331 ++++++++++++++++++ .../MiniSpace.Services.Reactions.sln | 48 +++ MiniSpace.Services.Reactions/scripts/build.sh | 2 + MiniSpace.Services.Reactions/scripts/start.sh | 4 + MiniSpace.Services.Reactions/scripts/test.sh | 2 + .../MiniSpace.Services.Reactions.Api.csproj | 14 + .../MiniSpace.Services.Reactions.Api.http | 6 + .../Program.cs | 44 +++ .../Properties/launchSettings.json | 41 +++ .../appsettings.Development.json | 8 + .../appsettings.json | 9 + .../Class1.cs | 6 + ...pace.Services.Reactions.Application.csproj | 9 + .../Class1.cs | 6 + .../MiniSpace.Services.Reactions.Core.csproj | 9 + .../Class1.cs | 6 + ...e.Services.Reactions.Infrastructure.csproj | 9 + 17 files changed, 554 insertions(+) create mode 100644 MiniSpace.Services.Reactions/.gitignore create mode 100644 MiniSpace.Services.Reactions/MiniSpace.Services.Reactions.sln create mode 100644 MiniSpace.Services.Reactions/scripts/build.sh create mode 100644 MiniSpace.Services.Reactions/scripts/start.sh create mode 100644 MiniSpace.Services.Reactions/scripts/test.sh create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.json create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/MiniSpace.Services.Reactions.Core.csproj create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/Class1.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj diff --git a/MiniSpace.Services.Reactions/.gitignore b/MiniSpace.Services.Reactions/.gitignore new file mode 100644 index 000000000..c1aafb511 --- /dev/null +++ b/MiniSpace.Services.Reactions/.gitignore @@ -0,0 +1,331 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +# **/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +logs/ \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/MiniSpace.Services.Reactions.sln b/MiniSpace.Services.Reactions/MiniSpace.Services.Reactions.sln new file mode 100644 index 000000000..5823effcb --- /dev/null +++ b/MiniSpace.Services.Reactions/MiniSpace.Services.Reactions.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E78E3850-ECCC-443C-B325-9F13D1639D46}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniSpace.Services.Reactions.Api", "src\MiniSpace.Services.Reactions.Api\MiniSpace.Services.Reactions.Api.csproj", "{05081A01-8BBE-4BB3-931C-4F33F78A7571}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniSpace.Services.Reactions.Application", "src\MiniSpace.Services.Reactions.Application\MiniSpace.Services.Reactions.Application.csproj", "{E122069F-329F-4400-8B3A-057BC704F5FC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniSpace.Services.Reactions.Core", "src\MiniSpace.Services.Reactions.Core\MiniSpace.Services.Reactions.Core.csproj", "{6B7F5638-AC31-482B-B806-D7AE537D0A10}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniSpace.Services.Reactions.Infrastructure", "src\MiniSpace.Services.Reactions.Infrastructure\MiniSpace.Services.Reactions.Infrastructure.csproj", "{DC4D92C4-18F6-463B-BD20-C9BEE5F9267F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {05081A01-8BBE-4BB3-931C-4F33F78A7571}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {05081A01-8BBE-4BB3-931C-4F33F78A7571}.Debug|Any CPU.Build.0 = Debug|Any CPU + {05081A01-8BBE-4BB3-931C-4F33F78A7571}.Release|Any CPU.ActiveCfg = Release|Any CPU + {05081A01-8BBE-4BB3-931C-4F33F78A7571}.Release|Any CPU.Build.0 = Release|Any CPU + {E122069F-329F-4400-8B3A-057BC704F5FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E122069F-329F-4400-8B3A-057BC704F5FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E122069F-329F-4400-8B3A-057BC704F5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E122069F-329F-4400-8B3A-057BC704F5FC}.Release|Any CPU.Build.0 = Release|Any CPU + {6B7F5638-AC31-482B-B806-D7AE537D0A10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B7F5638-AC31-482B-B806-D7AE537D0A10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B7F5638-AC31-482B-B806-D7AE537D0A10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B7F5638-AC31-482B-B806-D7AE537D0A10}.Release|Any CPU.Build.0 = Release|Any CPU + {DC4D92C4-18F6-463B-BD20-C9BEE5F9267F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC4D92C4-18F6-463B-BD20-C9BEE5F9267F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC4D92C4-18F6-463B-BD20-C9BEE5F9267F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC4D92C4-18F6-463B-BD20-C9BEE5F9267F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {05081A01-8BBE-4BB3-931C-4F33F78A7571} = {E78E3850-ECCC-443C-B325-9F13D1639D46} + {E122069F-329F-4400-8B3A-057BC704F5FC} = {E78E3850-ECCC-443C-B325-9F13D1639D46} + {6B7F5638-AC31-482B-B806-D7AE537D0A10} = {E78E3850-ECCC-443C-B325-9F13D1639D46} + {DC4D92C4-18F6-463B-BD20-C9BEE5F9267F} = {E78E3850-ECCC-443C-B325-9F13D1639D46} + EndGlobalSection +EndGlobal diff --git a/MiniSpace.Services.Reactions/scripts/build.sh b/MiniSpace.Services.Reactions/scripts/build.sh new file mode 100644 index 000000000..3affad0eb --- /dev/null +++ b/MiniSpace.Services.Reactions/scripts/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +dotnet build -c release \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/scripts/start.sh b/MiniSpace.Services.Reactions/scripts/start.sh new file mode 100644 index 000000000..2aae1b7b1 --- /dev/null +++ b/MiniSpace.Services.Reactions/scripts/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +export ASPNETCORE_ENVIRONMENT=local +cd ../src/MiniSpace.Services.Reactions.Api +dotnet run \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/scripts/test.sh b/MiniSpace.Services.Reactions/scripts/test.sh new file mode 100644 index 000000000..6046c35a0 --- /dev/null +++ b/MiniSpace.Services.Reactions/scripts/test.sh @@ -0,0 +1,2 @@ +#!/bin/bash +dotnet test \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj new file mode 100644 index 000000000..d455a7a4f --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http new file mode 100644 index 000000000..996c35df9 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http @@ -0,0 +1,6 @@ +@MiniSpace.Services.Reactions.Api_HostAddress = http://localhost:5151 + +GET {{MiniSpace.Services.Reactions.Api_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs new file mode 100644 index 000000000..fda9a7d58 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs @@ -0,0 +1,44 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +app.MapGet("/weatherforecast", () => +{ + var forecast = Enumerable.Range(1, 5).Select(index => + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) + .ToArray(); + return forecast; +}) +.WithName("GetWeatherForecast") +.WithOpenApi(); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json new file mode 100644 index 000000000..4123d48f1 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:36927", + "sslPort": 44364 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5151", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7293;http://localhost:5151", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json new file mode 100644 index 000000000..ff66ba6b2 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.json b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.json new file mode 100644 index 000000000..4d566948d --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs new file mode 100644 index 000000000..cd737b073 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs @@ -0,0 +1,6 @@ +namespace MiniSpace.Services.Reactions.Application; + +public class Class1 +{ + +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj new file mode 100644 index 000000000..bb23fb7d6 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs new file mode 100644 index 000000000..374e28f81 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs @@ -0,0 +1,6 @@ +namespace MiniSpace.Services.Reactions.Core; + +public class Class1 +{ + +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/MiniSpace.Services.Reactions.Core.csproj b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/MiniSpace.Services.Reactions.Core.csproj new file mode 100644 index 000000000..bb23fb7d6 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/MiniSpace.Services.Reactions.Core.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/Class1.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/Class1.cs new file mode 100644 index 000000000..fc7e932cc --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/Class1.cs @@ -0,0 +1,6 @@ +namespace MiniSpace.Services.Reactions.Infrastructure; + +public class Class1 +{ + +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj new file mode 100644 index 000000000..bb23fb7d6 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + From 3ba8ff73f1971c352686780346ec68e8825b1071 Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sun, 21 Apr 2024 09:43:16 +0200 Subject: [PATCH 008/319] (#48) Update project structure --- MiniSpace.Services.Reactions/.gitignore | 2 + .../MiniSpace.Services.Reactions.Api.csproj | 14 +- .../MiniSpace.Services.Reactions.Api.http | 6 - .../Program.cs | 81 ++++--- .../Properties/launchSettings.json | 33 +-- .../appsettings.Development.json | 6 - .../appsettings.local.json | 199 ++++++++++++++++++ ...pace.Services.Reactions.Application.csproj | 14 +- .../Class1.cs | 6 - ...e.Services.Reactions.Infrastructure.csproj | 32 ++- 10 files changed, 302 insertions(+), 91 deletions(-) delete mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.local.json delete mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs diff --git a/MiniSpace.Services.Reactions/.gitignore b/MiniSpace.Services.Reactions/.gitignore index c1aafb511..3cc443daf 100644 --- a/MiniSpace.Services.Reactions/.gitignore +++ b/MiniSpace.Services.Reactions/.gitignore @@ -3,6 +3,8 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +.vscode + # User-specific files *.suo *.user diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj index d455a7a4f..95a555ad0 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.csproj @@ -2,13 +2,19 @@ net8.0 - enable - enable + latest + MiniSpace.Services.Reactions.Api - - + + + + + + + + diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http deleted file mode 100644 index 996c35df9..000000000 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/MiniSpace.Services.Reactions.Api.http +++ /dev/null @@ -1,6 +0,0 @@ -@MiniSpace.Services.Reactions.Api_HostAddress = http://localhost:5151 - -GET {{MiniSpace.Services.Reactions.Api_HostAddress}}/weatherforecast/ -Accept: application/json - -### diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs index fda9a7d58..40ae9e3cc 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs @@ -1,44 +1,39 @@ -var builder = WebApplication.CreateBuilder(args); - -// Add services to the container. -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); - -var app = builder.Build(); - -// Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} - -app.UseHttpsRedirection(); - -var summaries = new[] -{ - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" -}; - -app.MapGet("/weatherforecast", () => -{ - var forecast = Enumerable.Range(1, 5).Select(index => - new WeatherForecast - ( - DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - Random.Shared.Next(-20, 55), - summaries[Random.Shared.Next(summaries.Length)] - )) - .ToArray(); - return forecast; -}) -.WithName("GetWeatherForecast") -.WithOpenApi(); - -app.Run(); - -record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +using System.Collections.Generic; +using System.Threading.Tasks; +using Convey; +using Convey.Logging; +using Convey.Types; +using Convey.WebApi; +using Convey.WebApi.CQRS; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace MiniSpace.Services.Reactions.Api { - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); -} + public class Program + { + public static async Task Main(string[] args) + => await WebHost.CreateDefaultBuilder(args) + .ConfigureServices(services => services + .AddConvey() + .AddWebApi() + //.AddApplication() + //.AddInfrastructure() + .Build()) + .Configure(app => app + //.UseInfrastructure() + .UseDispatcherEndpoints(endpoints => endpoints + .Get("", ctx => ctx.Response.WriteAsync(ctx.RequestServices.GetService().Name)) + //.Get>("posts") + //.Put("posts/{postId}") + //.Delete("posts/{postId}") + //.Post("posts", afterDispatch: (cmd, ctx) => ctx.Response.Created($"posts/{cmd.PostId}")) + //.Put("posts/{postId}/state/{state}", afterDispatch: (cmd, ctx) => ctx.Response.NoContent()) + )) + .UseLogging() + .Build() + .RunAsync(); + } +} \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json index 4123d48f1..9712e690f 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Properties/launchSettings.json @@ -1,40 +1,25 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:36927", - "sslPort": 44364 + "applicationUrl": "http://localhost:5013" } }, "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "http://localhost:5151", + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": false, "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "local" } }, - "https": { + "MiniSpace.Services.Students": { "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:7293;http://localhost:5151", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", + "launchBrowser": false, + "applicationUrl": "http://localhost:5013", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "local" } } } diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json index ff66ba6b2..f3ee419db 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.Development.json @@ -1,8 +1,2 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } } diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.local.json b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.local.json new file mode 100644 index 000000000..3fe61bdba --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/appsettings.local.json @@ -0,0 +1,199 @@ +{ + "app": { + "name": "MiniSpace Reactions Service", + "service": "reactions-service", + "version": "1" + }, + "consul": { + "enabled": true, + "url": "http://localhost:8500", + "service": "reactions-service", + "address": "docker.for.win.localhost", + "port": "5013", + "pingEnabled": false, + "pingEndpoint": "ping", + "pingInterval": 3, + "removeAfterInterval": 3 + }, + "fabio": { + "enabled": true, + "url": "http://localhost:9999", + "service": "reactions-service" + }, + "httpClient": { + "type": "fabio", + "retries": 3, + "services": {}, + "requestMasking": { + "enabled": true, + "maskTemplate": "*****" + } + }, + "jwt": { + "certificate": { + "location": "certs/localhost.pfx", + "password": "test", + "rawData": "" + }, + "issuerSigningKey": "eiquief5phee9pazo0Faegaez9gohThailiur5woy2befiech1oarai4aiLi6ahVecah3ie9Aiz6Peij", + "expiryMinutes": 60, + "issuer": "minispace", + "validateAudience": false, + "validateIssuer": false, + "validateLifetime": false, + "allowAnonymousEndpoints": ["/sign-in", "/sign-up"] + }, + "logger": { + "level": "information", + "excludePaths": ["/", "/ping", "/metrics"], + "excludeProperties": [ + "api_key", + "access_key", + "ApiKey", + "ApiSecret", + "ClientId", + "ClientSecret", + "ConnectionString", + "Password", + "Email", + "Login", + "Secret", + "Token" + ], + "console": { + "enabled": true + }, + "elk": { + "enabled": false, + "url": "http://localhost:9200" + }, + "file": { + "enabled": true, + "path": "logs/logs.txt", + "interval": "day" + }, + "seq": { + "enabled": true, + "url": "http://localhost:5341", + "apiKey": "secret" + }, + "tags": {} + }, + "jaeger": { + "enabled": true, + "serviceName": "reactions", + "udpHost": "localhost", + "udpPort": 6831, + "maxPacketSize": 0, + "sampler": "const", + "excludePaths": ["/", "/ping", "/metrics"] + }, + "metrics": { + "enabled": true, + "influxEnabled": false, + "prometheusEnabled": true, + "influxUrl": "http://localhost:8086", + "database": "minispace", + "env": "local", + "interval": 5 + }, + "mongo": { + "connectionString": "mongodb+srv://minispace-user:9vd6IxYWUuuqhzEH@cluster0.mmhq4pe.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0", + "database": "reactions-service", + "seed": false + }, + "outbox": { + "enabled": true, + "type": "sequential", + "expiry": 3600, + "intervalMilliseconds": 2000, + "inboxCollection": "inbox", + "outboxCollection": "outbox", + "disableTransactions": true + }, + "rabbitMq": { + "connectionName": "reactions-service", + "retries": 3, + "retryInterval": 2, + "conventionsCasing": "snakeCase", + "logger": { + "enabled": true + }, + "username": "guest", + "password": "guest", + "virtualHost": "/", + "port": 5672, + "hostnames": [ + "localhost" + ], + "requestedConnectionTimeout": "00:00:30", + "requestedHeartbeat": "00:01:00", + "socketReadTimeout": "00:00:30", + "socketWriteTimeout": "00:00:30", + "continuationTimeout": "00:00:20", + "handshakeContinuationTimeout": "00:00:10", + "networkRecoveryInterval": "00:00:05", + "exchange": { + "declare": true, + "durable": true, + "autoDelete": false, + "type": "topic", + "name": "reactions" + }, + "queue": { + "declare": true, + "durable": true, + "exclusive": false, + "autoDelete": false, + "template": "reactions-service/{{exchange}}.{{message}}" + }, + "context": { + "enabled": true, + "header": "message_context" + }, + "spanContextHeader": "span_context" + }, + "redis": { + "connectionString": "localhost", + "instance": "reactions:" + }, + "swagger": { + "enabled": true, + "reDocEnabled": false, + "name": "v1", + "title": "API", + "version": "v1", + "routePrefix": "docs", + "includeSecurity": true + }, + "vault": { + "enabled": true, + "url": "http://localhost:8200", + "authType": "token", + "token": "secret", + "username": "user", + "password": "secret", + "kv": { + "enabled": true, + "engineVersion": 2, + "mountPoint": "kv", + "path": "reactions-service/settings" + }, + "pki": { + "enabled": true, + "roleName": "reactions-service", + "commonName": "reactions-service.minispace.io" + }, + "lease": { + "mongo": { + "type": "database", + "roleName": "reactions-service", + "enabled": true, + "autoRenewal": true, + "templates": { + "connectionString": "mongodb://{{username}}:{{password}}@localhost:27017" + } + } + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj index bb23fb7d6..655099070 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/MiniSpace.Services.Reactions.Application.csproj @@ -3,7 +3,19 @@ net8.0 enable - enable + disable + + + + + + + + + + + + diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs deleted file mode 100644 index 374e28f81..000000000 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Class1.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MiniSpace.Services.Reactions.Core; - -public class Class1 -{ - -} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj index bb23fb7d6..c81a53625 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Infrastructure/MiniSpace.Services.Reactions.Infrastructure.csproj @@ -3,7 +3,37 @@ net8.0 enable - enable + disable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From cc7464da392c13f3799f9ab1f58d9b1d3b1b419a Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sun, 21 Apr 2024 10:09:21 +0200 Subject: [PATCH 009/319] (#48) Add domain event, exception and aggregates in Core --- .../Entities/AggregateId.cs | 50 +++++++++++++++++++ .../Entities/AggregateRoot.cs | 19 +++++++ .../Events/IDomainEvent.cs | 7 +++ .../Exceptions/DomainException.cs | 11 ++++ .../Exceptions/InvalidAggregateIdException.cs | 11 ++++ 5 files changed, 98 insertions(+) create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateId.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateRoot.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Events/IDomainEvent.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/DomainException.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidAggregateIdException.cs diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateId.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateId.cs new file mode 100644 index 000000000..2ddc1effb --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateId.cs @@ -0,0 +1,50 @@ +using MiniSpace.Services.Reactions.Core.Exceptions; + +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public class AggregateId : IEquatable + { + public Guid Value { get; } + + public AggregateId() + { + Value = Guid.NewGuid(); + } + + public AggregateId(Guid value) + { + if (value == Guid.Empty) + { + throw new InvalidAggregateIdException(); + } + + Value = value; + } + + public bool Equals(AggregateId other) + { + if (ReferenceEquals(null, other)) return false; + return ReferenceEquals(this, other) || Value.Equals(other.Value); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((AggregateId) obj); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static implicit operator Guid(AggregateId id) + => id.Value; + + public static implicit operator AggregateId(Guid id) + => new AggregateId(id); + + public override string ToString() => Value.ToString(); + } +} \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateRoot.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateRoot.cs new file mode 100644 index 000000000..0a5326133 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/AggregateRoot.cs @@ -0,0 +1,19 @@ +using MiniSpace.Services.Reactions.Core.Events; + +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public abstract class AggregateRoot + { + private readonly List _events = new List(); + public IEnumerable Events => _events; + public AggregateId Id { get; protected set; } + public int Version { get; protected set; } + + protected void AddEvent(IDomainEvent @event) + { + _events.Add(@event); + } + + public void ClearEvents() => _events.Clear(); + } +} \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Events/IDomainEvent.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Events/IDomainEvent.cs new file mode 100644 index 000000000..8825fe8cd --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Events/IDomainEvent.cs @@ -0,0 +1,7 @@ +namespace MiniSpace.Services.Reactions.Core.Events +{ + public interface IDomainEvent + { + + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/DomainException.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/DomainException.cs new file mode 100644 index 000000000..a8d371b2b --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/DomainException.cs @@ -0,0 +1,11 @@ +namespace MiniSpace.Services.Reactions.Core.Exceptions +{ + public abstract class DomainException : Exception + { + public virtual string Code { get; } + + protected DomainException(string message) : base(message) + { + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidAggregateIdException.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidAggregateIdException.cs new file mode 100644 index 000000000..4b0d05ab0 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidAggregateIdException.cs @@ -0,0 +1,11 @@ +namespace MiniSpace.Services.Reactions.Core.Exceptions +{ + public class InvalidAggregateIdException : DomainException + { + public override string Code { get; } = "invalid_aggregate_id"; + + public InvalidAggregateIdException() : base($"Invalid aggregate id.") + { + } + } +} From 5f3e9965a14ba1516406f659cdfa36c258d267f3 Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sun, 21 Apr 2024 10:15:35 +0200 Subject: [PATCH 010/319] (#48) Add Student entity and interface for Student repository --- .../Entities/Student.cs | 14 ++++++++++++++ .../Repositories/IStudentRepository.cs | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Student.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IStudentRepository.cs diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Student.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Student.cs new file mode 100644 index 000000000..be9997500 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Student.cs @@ -0,0 +1,14 @@ +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public class Student + { + public Guid Id { get; private set; } + public string FullName { get; private set; } + + public Student(Guid id, string fullName) + { + Id = id; + FullName = fullName; + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IStudentRepository.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IStudentRepository.cs new file mode 100644 index 000000000..293aafde6 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IStudentRepository.cs @@ -0,0 +1,12 @@ +using MiniSpace.Services.Reactions.Core.Entities; + +namespace MiniSpace.Services.Reactions.Core.Repositories +{ + public interface IStudentRepository + { + Task GetAsync(Guid id); + Task ExistsAsync(Guid id); + Task AddAsync(Student student); + Task DeleteAsync(Guid id); + } +} From 3870d8a4ecdbb645b16d9f0151e0c625405e4186 Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sun, 21 Apr 2024 10:32:03 +0200 Subject: [PATCH 011/319] (#48) Add AppException, some extensions and interfaces for services in Application --- .../MiniSpace.Services.Reactions.Api/Program.cs | 3 ++- .../Class1.cs | 6 ------ .../Exceptions/AppException.cs | 11 +++++++++++ .../Extensions.cs | 16 ++++++++++++++++ .../Services/IEventMapper.cs | 11 +++++++++++ .../Services/IMessageBroker.cs | 10 ++++++++++ 6 files changed, 50 insertions(+), 7 deletions(-) delete mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/AppException.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Extensions.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IEventMapper.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IMessageBroker.cs diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs index 40ae9e3cc..fa6d44325 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using MiniSpace.Services.Reactions.Application; namespace MiniSpace.Services.Reactions.Api { @@ -19,7 +20,7 @@ public static async Task Main(string[] args) .ConfigureServices(services => services .AddConvey() .AddWebApi() - //.AddApplication() + .AddApplication() //.AddInfrastructure() .Build()) .Configure(app => app diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs deleted file mode 100644 index cd737b073..000000000 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Class1.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MiniSpace.Services.Reactions.Application; - -public class Class1 -{ - -} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/AppException.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/AppException.cs new file mode 100644 index 000000000..c35340ae3 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/AppException.cs @@ -0,0 +1,11 @@ +namespace MiniSpace.Services.Reactions.Application.Exceptions +{ + public class AppException : Exception + { + public virtual string Code { get; } + + protected AppException(string message) : base(message) + { + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Extensions.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Extensions.cs new file mode 100644 index 000000000..eedc5326f --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Extensions.cs @@ -0,0 +1,16 @@ +using Convey; +using Convey.CQRS.Commands; +using Convey.CQRS.Events; + +namespace MiniSpace.Services.Reactions.Application +{ + public static class Extensions + { + public static IConveyBuilder AddApplication(this IConveyBuilder builder) + => builder + .AddCommandHandlers() + .AddEventHandlers() + .AddInMemoryCommandDispatcher() + .AddInMemoryEventDispatcher(); + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IEventMapper.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IEventMapper.cs new file mode 100644 index 000000000..65cbe1c90 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IEventMapper.cs @@ -0,0 +1,11 @@ +using Convey.CQRS.Events; +using MiniSpace.Services.Reactions.Core.Events; + +namespace MiniSpace.Services.Reactions.Application.Services +{ + public interface IEventMapper + { + IEvent Map(IDomainEvent @event); + IEnumerable MapAll(IEnumerable events); + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IMessageBroker.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IMessageBroker.cs new file mode 100644 index 000000000..dc95763b7 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Services/IMessageBroker.cs @@ -0,0 +1,10 @@ +using Convey.CQRS.Events; + +namespace MiniSpace.Services.Reactions.Application.Services +{ + public interface IMessageBroker + { + Task PublishAsync(params IEvent[] events); + Task PublishAsync(IEnumerable events); + } +} From fe12c295555228a43658aae8cb1c757cd8376263 Mon Sep 17 00:00:00 2001 From: olegkiprik Date: Sun, 21 Apr 2024 12:07:12 +0200 Subject: [PATCH 012/319] (#48) Add some essential functionality --- .../Program.cs | 5 +++ .../Commands/CreateReaction.cs | 26 +++++++++++ .../Commands/DeleteReaction.cs | 22 +++++++++ .../Handlers/CreateReactionHandler.cs | 45 +++++++++++++++++++ .../Handlers/DeleteReactionHandler.cs | 43 ++++++++++++++++++ .../Dto/ReactionDto.cs | 9 ++++ .../Exceptions/StudentNotFoundException.cs | 13 ++++++ .../Queries/GetReactions.cs | 13 ++++++ .../Queries/GetReactionsSummary.cs | 13 ++++++ .../Entities/ContentType.cs | 8 ++++ .../Entities/PostState.cs | 11 +++++ .../Entities/Reaction.cs | 23 ++++++++++ .../Entities/ReactionContainer.cs | 19 ++++++++ .../Entities/ReactionType.cs | 11 +++++ .../InvalidReactionTypeException.cs | 14 ++++++ .../Repositories/IPostRepository.cs | 13 ++++++ .../Repositories/IReactionRepository.cs | 13 ++++++ 17 files changed, 301 insertions(+) create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/CreateReaction.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/DeleteReaction.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/CreateReactionHandler.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/DeleteReactionHandler.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Dto/ReactionDto.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/StudentNotFoundException.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactions.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactionsSummary.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ContentType.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/PostState.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Reaction.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionContainer.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionType.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidReactionTypeException.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IPostRepository.cs create mode 100644 MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IReactionRepository.cs diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs index fa6d44325..df76da2c1 100644 --- a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api/Program.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using MiniSpace.Services.Reactions.Application; +using MiniSpace.Services.Reactions.Application.Commands; namespace MiniSpace.Services.Reactions.Api { @@ -27,6 +28,10 @@ public static async Task Main(string[] args) //.UseInfrastructure() .UseDispatcherEndpoints(endpoints => endpoints .Get("", ctx => ctx.Response.WriteAsync(ctx.RequestServices.GetService().Name)) + .Post("reactions" + //, afterDispatch: (cmd, ctx) => ctx.Response.Created($"reactions/{cmd.ReactionId}") + ) + .Delete("reactions/{reactionId}") //.Get>("posts") //.Put("posts/{postId}") //.Delete("posts/{postId}") diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/CreateReaction.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/CreateReaction.cs new file mode 100644 index 000000000..f02dbf9f1 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/CreateReaction.cs @@ -0,0 +1,26 @@ +using System.Data; +using Convey.CQRS.Commands; +using MiniSpace.Services.Reactions.Core.Entities; + +namespace MiniSpace.Services.Reactions.Application.Commands +{ + public class CreateReaction : ICommand + { + public Guid StudentId { get; } + public string StudentFullName { get; } + + public string ReactionType { get; } + + // Is the reaction related to event or post? + public string ContentType { get; } + + public CreateReaction(Guid studentId, string studentFullName, + string reactionType, string contentType) + { + StudentId = studentId; + StudentFullName = studentFullName; + ReactionType = reactionType; + ContentType = contentType; + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/DeleteReaction.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/DeleteReaction.cs new file mode 100644 index 000000000..6617792e3 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/DeleteReaction.cs @@ -0,0 +1,22 @@ +using System.Reflection.Metadata; +using Convey.CQRS.Commands; +using Microsoft.AspNetCore.Mvc.TagHelpers; +using MiniSpace.Services.Reactions.Core.Entities; + +namespace MiniSpace.Services.Reactions.Application.Commands +{ + public class DeleteReaction : ICommand + { + public Guid StudentId; + public Guid ContentId; + public ReactionContentType ContentType; + + public DeleteReaction(Guid studentId, Guid contentId, + ReactionContentType contentType) + { + StudentId = studentId; + ContentId = contentId; + ContentType = contentType; + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/CreateReactionHandler.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/CreateReactionHandler.cs new file mode 100644 index 000000000..5bcd7c918 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/CreateReactionHandler.cs @@ -0,0 +1,45 @@ +using Convey.CQRS.Commands; +using MiniSpace.Services.Reactions.Application.Exceptions; +using MiniSpace.Services.Reactions.Core.Entities; +using MiniSpace.Services.Reactions.Core.Exceptions; +using MiniSpace.Services.Reactions.Core.Repositories; + +namespace MiniSpace.Services.Reactions.Application.Commands.Handlers +{ + public class CreateReactionHandler : ICommandHandler + { + private readonly IReactionRepository _reactionRepository; + private readonly IStudentRepository _studentRepository; + //private readonly IDateTimeProvider _dateTimeProvider; + //private readonly IMessageBroker _messageBroker; + + public CreateReactionHandler(IReactionRepository reactionRepository, IStudentRepository studentRepository + //,IDateTimeProvider dateTimeProvider + //, IMessageBroker messageBroker + ) + { + _reactionRepository = reactionRepository; + _studentRepository = studentRepository; + //_dateTimeProvider = dateTimeProvider; + //_messageBroker = messageBroker; + } + + public async Task HandleAsync(CreateReaction command, CancellationToken cancellationToken = default) + { + if (!(await _studentRepository.ExistsAsync(command.StudentId))) + { + throw new StudentNotFoundException(command.StudentId); + } + + if (!Enum.TryParse(command.ReactionType, true, out var newReactionType)) + { + throw new InvalidReactionTypeException(command.ReactionType); + } + + var reaction = Reaction.Create(command.StudentId, command.StudentFullName, newReactionType); + await _reactionRepository.AddAsync(reaction); + + //await _messageBroker.PublishAsync(new ReactionCreated(command.ReactionId)); + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/DeleteReactionHandler.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/DeleteReactionHandler.cs new file mode 100644 index 000000000..27200c564 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Commands/Handlers/DeleteReactionHandler.cs @@ -0,0 +1,43 @@ +using Convey.CQRS.Commands; +using MiniSpace.Services.Reactions.Application.Commands; +using MiniSpace.Services.Reactions.Core.Entities; +using MiniSpace.Services.Reactions.Core.Repositories; + +namespace MiniSpace.Services.Reactions.Application.Commands.Handlers +{ + public class DeleteReactionHandler : ICommandHandler + { + private readonly IStudentRepository _studentRepository; + //private readonly IEventRepository _eventRepository; + private readonly IPostRepository _postRepository; + + public DeleteReactionHandler(IStudentRepository studentRepository, + //IEventRepository eventRepository, + IPostRepository postRepository) + { + _studentRepository = studentRepository; + //_eventRepository = eventRepository; + _postRepository = postRepository; + } + + public async Task HandleAsync(DeleteReaction command, CancellationToken cancellationToken = default) + { + // switch (command.ContentType) { + // case ReactionContentType.Event: + // var @event = await _eventRepository.GetAsync(command.ContentId); + // if (@event is null) { + // throw new EventNotFoundException(command.ContentId); + // } + // break; + // case ReactionContentType.Post: + // var post = await _postRepository.GetAsync(command.ContentId); + // if (post is null) { + // throw new PostNotFoundException(command.ContentId); + // } + // break; + // } + + // await _postRepository.DeleteAsync(command.PostId); + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Dto/ReactionDto.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Dto/ReactionDto.cs new file mode 100644 index 000000000..e1fcc1938 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Dto/ReactionDto.cs @@ -0,0 +1,9 @@ + +namespace MiniSpace.Services.Reactions.Application.Dto +{ + public class ReactionDto + { + public string ReactionType; + public Guid StudentId { get; set; } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/StudentNotFoundException.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/StudentNotFoundException.cs new file mode 100644 index 000000000..4c64b8d43 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Exceptions/StudentNotFoundException.cs @@ -0,0 +1,13 @@ +namespace MiniSpace.Services.Reactions.Application.Exceptions +{ + public class StudentNotFoundException : AppException + { + public override string Code { get; } = "student_not_found"; + public Guid Id { get; } + + public StudentNotFoundException(Guid id) : base($"Student with id: {id} was not found.") + { + Id = id; + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactions.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactions.cs new file mode 100644 index 000000000..35da121ab --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactions.cs @@ -0,0 +1,13 @@ + +using Convey.CQRS.Queries; +using MiniSpace.Services.Reactions.Application.Dto; +using MiniSpace.Services.Reactions.Core.Entities; + +namespace MiniSpace.Services.Reactions.Application.Queries +{ + public class GetReactions : IQuery> + { + public Guid ContentId { get; set; } + public ReactionContentType ContentType { get; set; } + } +} \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactionsSummary.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactionsSummary.cs new file mode 100644 index 000000000..c5993d6b4 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Application/Queries/GetReactionsSummary.cs @@ -0,0 +1,13 @@ + +using Convey.CQRS.Queries; +using MiniSpace.Services.Reactions.Application.Dto; +using MiniSpace.Services.Reactions.Core.Entities; + +namespace MiniSpace.Services.Reactions.Application.Queries +{ + public class GetReactionsSummary : IQuery> + { + public Guid ContentId { get; set; } + public ReactionContentType ContentType { get; set; } + } +} \ No newline at end of file diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ContentType.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ContentType.cs new file mode 100644 index 000000000..72dc6249a --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ContentType.cs @@ -0,0 +1,8 @@ +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public enum ReactionContentType + { + Event, + Post + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/PostState.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/PostState.cs new file mode 100644 index 000000000..b9a36a4a3 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/PostState.cs @@ -0,0 +1,11 @@ +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public enum PostState + { + ToBePublished, + Published, + InDraft, + Hidden, + Reported + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Reaction.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Reaction.cs new file mode 100644 index 000000000..09f5610ba --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/Reaction.cs @@ -0,0 +1,23 @@ +using MiniSpace.Services.Reactions.Core.Exceptions; + +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public class Reaction : AggregateRoot + { + public Guid StudentId { get; private set; } + public string StudentFullName { get; private set; } + public ReactionType ReactionType { get; private set; } + + public Reaction(Guid studentId, string studentFullName, ReactionType reactionType) + { + StudentId = studentId; + StudentFullName = studentFullName; + ReactionType = reactionType; + } + + public static Reaction Create(Guid studentId, string studentFullName, ReactionType reactionType) + { + return new Reaction(studentId, studentFullName, reactionType); + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionContainer.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionContainer.cs new file mode 100644 index 000000000..9256b0b08 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionContainer.cs @@ -0,0 +1,19 @@ + +using System.ComponentModel; + +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public class ReactionContainer + { + public Guid ContentId; + public ReactionContentType ContentType; + IEnumerable Reactions; + + public ReactionContainer(Guid contentId, ReactionContentType contentType, IEnumerable reactions) + { + ContentId = contentId; + ContentType = contentType; + Reactions = reactions; + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionType.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionType.cs new file mode 100644 index 000000000..8d96e5850 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Entities/ReactionType.cs @@ -0,0 +1,11 @@ +namespace MiniSpace.Services.Reactions.Core.Entities +{ + public enum ReactionType + { + LoveIt, + LikeIt, + Wow, + ItWasOkay, + HateIt + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidReactionTypeException.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidReactionTypeException.cs new file mode 100644 index 000000000..c15dfd781 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Exceptions/InvalidReactionTypeException.cs @@ -0,0 +1,14 @@ +namespace MiniSpace.Services.Reactions.Core.Exceptions +{ + public class InvalidReactionTypeException : DomainException + { + public override string Code { get; } = "invalid_post_state"; + public string InvalidReactionType { get; } + + public InvalidReactionTypeException(string invalidReactionType) : base( + $"String: {invalidReactionType} cannot be parsed to valid reaction type.") + { + InvalidReactionType = invalidReactionType; + } + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IPostRepository.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IPostRepository.cs new file mode 100644 index 000000000..7d1578c55 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IPostRepository.cs @@ -0,0 +1,13 @@ +using MiniSpace.Services.Reactions.Core.Entities; + +namespace MiniSpace.Services.Reactions.Core.Repositories +{ + public interface IPostRepository + { + //Task GetAsync(Guid id); + //Task> GetToUpdateAsync(); + //Task AddAsync(Post post); + //Task UpdateAsync(Post post); + Task DeleteAsync(Guid id); + } +} diff --git a/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IReactionRepository.cs b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IReactionRepository.cs new file mode 100644 index 000000000..09d9f32d1 --- /dev/null +++ b/MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Core/Repositories/IReactionRepository.cs @@ -0,0 +1,13 @@ +using MiniSpace.Services.Reactions.Core.Entities; + +namespace MiniSpace.Services.Reactions.Core.Repositories +{ + public interface IReactionRepository + { + //Task GetAsync(Guid id); + //Task> GetToUpdateAsync(); + Task AddAsync(Reaction reaction); + //Task UpdateAsync(Reaction reaction); + //Task DeleteAsync(Guid id); + } +} From d25792b7beef75d115ad2617ed0969501ddc08aa Mon Sep 17 00:00:00 2001 From: eggwhat Date: Sun, 21 Apr 2024 12:30:13 +0200 Subject: [PATCH 013/319] (#57) fix a bug with identity service --- .../Areas/Identity/IdentityService.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs index c1507de43..76a7a9978 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Identity/IdentityService.cs @@ -33,12 +33,15 @@ public Task SignUpAsync(string firstName, string lastName, string email, string public async Task SignInAsync(string email, string password) { JwtDto = await _httpClient.PostAsync("identity/sign-in", new {email, password}); - - var jwtToken = _jwtHandler.ReadJwtToken(JwtDto.AccessToken); - var payload = jwtToken.Payload; - Name = (string)payload["name"]; - Email = (string)payload["e-mail"]; - IsAuthenticated = true; + + if (JwtDto != null) + { + var jwtToken = _jwtHandler.ReadJwtToken(JwtDto.AccessToken); + var payload = jwtToken.Payload; + Name = (string)payload["name"]; + Email = (string)payload["e-mail"]; + IsAuthenticated = true; + } return JwtDto; } From efc8df626e7846f9015bcbaa0350e2e5699132a0 Mon Sep 17 00:00:00 2001 From: eggwhat Date: Sun, 21 Apr 2024 14:15:54 +0200 Subject: [PATCH 014/319] (#57) fix get student events request in events service --- MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs index 3b3dbde48..a924e93e1 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs @@ -28,7 +28,8 @@ public Task GetEventAsync(Guid eventId) public Task>> GetStudentEventsAsync(Guid studentId, int numberOfResults) { _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); - return _httpClient.GetAsync>>($"events/student/{studentId}"); + return _httpClient.GetAsync>>( + $"events/student/{studentId}?numberOfResults={numberOfResults}"); } public Task AddEventAsync(Guid eventId, string name, Guid organizerId, DateTime startDate, DateTime endDate, From c1f9d69e311da845e400f8a253b7e4676566a729 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Sun, 21 Apr 2024 14:53:20 +0200 Subject: [PATCH 015/319] (#57) add dialog for filtering events --- .../Models/Events/SearchEventsModel.cs | 9 +- .../Pages/Dialogs/EventsSearchDialog.razor | 83 +++++++++++++++++++ .../MiniSpace.Web/Pages/EventsSearch.razor | 70 ++++++++++++---- .../src/MiniSpace.Web/Shared/MainLayout.razor | 52 ++++++------ MiniSpace.Web/src/MiniSpace.Web/Startup.cs | 3 + 5 files changed, 171 insertions(+), 46 deletions(-) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/Dialogs/EventsSearchDialog.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs b/MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs index 39a814b42..60d1a1d64 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Models/Events/SearchEventsModel.cs @@ -1,13 +1,14 @@ +using System; using MiniSpace.Web.DTO.Wrappers; namespace MiniSpace.Web.Models.Events { - public class SearchEventModel + public class SearchEventsModel { public string Name { get; set; } public string Organizer { get; set; } - public string DateFrom { get; set; } - public string DateTo { get; set; } + public DateTime DateFrom { get; set; } + public DateTime DateTo { get; set; } public PageableDto Pageable { get; set; } } -} \ No newline at end of file +} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Dialogs/EventsSearchDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Dialogs/EventsSearchDialog.razor new file mode 100644 index 000000000..1abb60a3d --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Dialogs/EventsSearchDialog.razor @@ -0,0 +1,83 @@ +@page "/events/search/dialog" +@using MiniSpace.Web.Models.Events +@using Radzen +@using MiniSpace.Web.DTO.Wrappers +@using Blazorise.DeepCloner +@inject NavigationManager NavigationManager +@inject Radzen.DialogService DialogService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +@code { + [Parameter] + public SearchEventsModel SearchEventsModel { get; set; } + + private SearchEventsModel TempSearchEventsModel { get; set; } + + private List directions = + [ + "Ascending", + "Descending" + ]; + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + TempSearchEventsModel = SearchEventsModel.DeepClone(); + } + + private void HandleFiltering() + { + SearchEventsModel.Name = TempSearchEventsModel.Name; + SearchEventsModel.Organizer = TempSearchEventsModel.Organizer; + SearchEventsModel.DateFrom = TempSearchEventsModel.DateFrom; + SearchEventsModel.DateTo = TempSearchEventsModel.DateTo; + SearchEventsModel.Pageable = TempSearchEventsModel.Pageable.DeepClone(); + + DialogService.Close(true); + } +} \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor index b68cc7e1c..b60bb297c 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/EventsSearch.razor @@ -4,12 +4,20 @@ @using MiniSpace.Web.DTO @using MiniSpace.Web.DTO.Wrappers @using MiniSpace.Web.Models.Events +@using MiniSpace.Web.Pages.Dialogs @using Radzen +@using DialogOptions = Radzen.DialogOptions +@using DialogService = Radzen.DialogService +@inject DialogService DialogService @inject IIdentityService IdentityService @inject IEventsService EventsService @inject NavigationManager NavigationManager -

Search events

+

Search events

+ +
+ +