Skip to content

Commit

Permalink
Merge pull request #88 from dotnetcameroon/develop
Browse files Browse the repository at this point in the history
Develop - Database optimization and code refactoring
  • Loading branch information
djoufson authored Dec 29, 2024
2 parents 20f8fd5 + 2154a8b commit 377b039
Show file tree
Hide file tree
Showing 114 changed files with 508 additions and 292 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# secret files
secrets/
hangfire.db*

# dotenv files
.env
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace app.Persistence;
namespace app.business.Persistence;

public interface IUnitOfWork
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using app.Models.EventAggregate;
using ErrorOr;
using Microsoft.Extensions.Caching.Memory;

namespace app.Services;
namespace app.business.Services;
public interface ICacheManager
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Linq.Expressions;
using app.Models.EventAggregate;
using app.Utilities;
using app.ViewModels;
using app.domain.Models.EventAggregate;
using app.domain.ViewModels;
using app.shared.Utilities;
using ErrorOr;

namespace app.Services;
namespace app.business.Services;
public interface IEventService
{
Task<ErrorOr<Event[]>> GetUpcomingAsync(int page = 1, int size = 2, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace app.Services;
namespace app.business.Services;
public interface IFileDownloader
{
Task<Stream> DownloadAsync(string fileId, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace app.Services;
namespace app.business.Services;
public interface IFileManager : IFileUploader, IFileDownloader
{
Task<bool> DeleteAsync(string fileName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace app.Services;
namespace app.business.Services;
public interface IFileUploader
{
Task<string> UploadAsync(Stream stream, string fileName, string relativeLocation, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using app.Models.Identity;
using app.domain.Models.Identity;
using ErrorOr;

namespace app.Services;
namespace app.business.Services;
public interface IIdentityService
{
Task<ErrorOr<User>> LoginAsync(string email, string password);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Linq.Expressions;
using app.Models.EventAggregate.Entities;
using app.Utilities;
using app.domain.Models.EventAggregate.Entities;
using app.shared.Utilities;
using ErrorOr;

namespace app.Services;
namespace app.business.Services;
public interface IPartnerService
{
Task<ErrorOr<Partner>> GetAsync(Guid id, CancellationToken cancellationToken = default);
Expand Down
13 changes: 13 additions & 0 deletions app.business/app.business.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\app.domain\app.domain.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using app.domain.Models.EventAggregate.Entities
<div class="gap-8 md:h-[300px] flex flex-col md:flex-row">
<div class="w-[230px]">
<img src="@Activity.Host.ImageUrl" alt="@Activity.Title" class="w-full md:h-full object-cover">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
@using app.Components.Pages.Admin.Events
@inject IJSRuntime JsInterop

<div id="activity-popup" class="activity-popup absolute top-0 left-0 w-full h-full z-10">
<div class="relative top-0 left-0 w-full h-full z-10">
<div class="fixed w-full h-full top-0 left-0 bg-black bg-opacity-30"></div>
<EditForm id="new-activity-form" OnValidSubmit="@Add" FormName="NewActivityForm" Model="@ActivityModel" class="absolute flex flex-col gap-4 p-4 justify-between items-center top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-10 w-[80%] h-[80%] bg-white rounded-lg">
<EditForm id="new-activity-form" OnValidSubmit="@Add" FormName="NewActivityForm" Model="@ActivityModel"
class="absolute flex flex-col gap-4 p-4 justify-between items-center top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-10 w-[80%] h-[80%] bg-white rounded-lg">
<div class="w-full flex gap-6 pt-10">
<div class="w-1/2">
<h2 class="heading heading-2">Details</h2>
<div class="w-full">
<label for="title-input" class="font-bold">
Title
</label>
<InputText id="title-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.Title" title="title" required placeholder="The activity name"/>
<InputText id="title-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.Title" title="title" required placeholder="The activity name" />
</div>
<div class="w-full mt-4">
<label for="description-input" class="font-bold">
<label for="activity-description-input" class="font-bold">
Description
</label>
<InputTextArea id="activity-description-input" onfocus="adjustTextareaHight('activity-description-input')" oninput="adjustTextareaHight('activity-description-input')" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.Description" title="description" required placeholder="The activity description"/>
<InputTextArea id="activity-description-input"
onfocus="adjustTextareaHeight('activity-description-input')"
oninput="adjustTextareaHeight('activity-description-input')"
class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.Description" title="description" required
placeholder="The activity description" />
</div>
<div class="w-full">
<p class="font-bold">Schedule</p>
<div class="flex flex-col">
<label>
<i class="fa-regular fa-calendar"></i> Start Time:
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.Start"/>
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.Start" />
</label>
<label>
<i class="fa-regular fa-calendar-minus"></i> End Time:
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.End"/>
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.End" />
</label>
</div>
</div>
Expand All @@ -41,21 +47,25 @@
Host Picture
</label>
<div class="flex items-center gap-2">
<img src="@ActivityModel.HostImageUrl" alt="@ActivityModel.HostName" class="block w-[50px] aspect-square"/>
<img src="@ActivityModel.HostImageUrl" alt="@ActivityModel.HostName"
class="block w-[50px] aspect-square" />
<InputFile OnChange="@HandleFileSelected" title="Choose host picture" accept="image/*" />
</div>
</div>
<div class="w-full mt-4">
<label for="host-name-input" class="font-bold">
Host Name
</label>
<InputText id="host-name-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.HostName" title="host name" required placeholder="Host name"/>
<InputText id="host-name-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.HostName" title="host name" required placeholder="Host name" />
</div>
<div class="w-full mt-4">
<label for="host-email-input" class="font-bold">
Host Email
</label>
<InputText id="host-email-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.HostEmail" title="host email" required placeholder="Host Email"/>
<InputText id="host-email-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.HostEmail" title="host email" required
placeholder="Host Email" />
</div>
</div>
</div>
Expand All @@ -67,7 +77,7 @@
</div>
</div>

@code{
@code {
private const string ActiveClass = "active";
private string _class = string.Empty;
[Parameter]
Expand All @@ -86,29 +96,24 @@
private async Task Add()
{
Parent.AddActivity(new ActivityModel
{
Title = ActivityModel.Title,
Description = ActivityModel.Description,
Host = new HostModel
{
Name = ActivityModel.HostName,
Email = ActivityModel.HostEmail,
ImageUrl = ActivityModel.HostImageUrl
},
Schedule = ActivitySchedule.Create(ActivityModel.Start, ActivityModel.End)
});
Title = ActivityModel.Title,
Description = ActivityModel.Description,
Host = new HostModel
{
Name = ActivityModel.HostName,
Email = ActivityModel.HostEmail,
ImageUrl = ActivityModel.HostImageUrl
},
Schedule = ActivitySchedule.Create(ActivityModel.Start, ActivityModel.End)
});
ActivityModel.HostImageUrl = string.Empty;
await JsInterop.InvokeVoidAsync("toggleActivityPopup");
}

private async Task HandleFileSelected(InputFileChangeEventArgs e)
{
var file = e.File;
if (file is null)
{
return;
}

using var memoryStream = new MemoryStream();
await file.OpenReadStream().CopyToAsync(memoryStream);
byte[] fileBytes = memoryStream.ToArray();
Expand All @@ -118,19 +123,19 @@
}

private async Task CloseActivityPopup()
{
{
ActivityModel.HostImageUrl = string.Empty;
await JsInterop.InvokeVoidAsync("toggleActivityPopup");
}

class Model
{
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string HostName { get; set; } = string.Empty;
public string HostEmail { get; set; } = string.Empty;
public string HostImageUrl { get; set; } = string.Empty;
public TimeOnly Start { get; set; } = new();
public TimeOnly End { get; set; } = new();
public TimeOnly Start { get; set; }
public TimeOnly End { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
</div>

@code{
public int Year => DateTime.Now.Year;
private int Year => DateTime.Now.Year;
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 377b039

Please sign in to comment.