Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.idea.Reservation_System/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/config/applicationhost.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Application.Features.Auth.Interfaces;
using Application.Features.Auth.Services;
using Application.Features.Service.Services;
using Application.Features.Tenant.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Application;

Expand All @@ -13,7 +14,8 @@ public static IServiceCollection AddApplication(this IServiceCollection services
services.AddScoped<IAppointmentService,AppointmentService>();
services.AddScoped<IServiceAppService,ServiceAppService>();
services.AddScoped<IUserService,UserService>();
services.AddScoped<IPasswordRecoveryService,PasswordRecoveryService>();
services.AddScoped<IPasswordRecoveryService, PasswordRecoveryService>();
services.AddScoped<TenantServiceContract,TenantService>();
return services;
}
}
8 changes: 8 additions & 0 deletions Application/Features/Tenant/DTO's/RegisterTenantDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Application.Features.Tenant.DTO_s;

public class RegisterTenantDTO
{
public string Name { get; set; }
public string Slug { get; set; }
public DateTime SubscriptionExpireDate { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Application.Features.Tenant.DTO_s;

namespace Application.Features.Tenant.Interfaces;

public interface TenantRepositoryContract
{
Task RegisterTenant(Domain.Entities.Tenant tenant);
Task SaveAsync();
}
24 changes: 24 additions & 0 deletions Application/Features/Tenant/Services/TenantService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Application.Features.Tenant.DTO_s;
using Application.Features.Tenant.Interfaces;
using Domain.Entities;
namespace Application.Features.Tenant.Services;

public class TenantService:TenantServiceContract
{
private readonly TenantRepositoryContract _tenantRepository;

public TenantService(TenantRepositoryContract tenantRepository)
{
_tenantRepository = tenantRepository;
}

public async Task<string> Register(RegisterTenantDTO dto)
{
//Todo: slug maker
// Todo : Date manager
var tenant = new Domain.Entities.Tenant(dto.Name,dto.Slug,dto.SubscriptionExpireDate);
await _tenantRepository.RegisterTenant(tenant);
await _tenantRepository.SaveAsync();
return $"{tenant.Name} Registered";
}
}
8 changes: 8 additions & 0 deletions Application/Features/Tenant/Services/TenantServiceContract.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Application.Features.Tenant.DTO_s;

namespace Application.Features.Tenant.Services;

public interface TenantServiceContract
{
Task<string> Register(RegisterTenantDTO dto);
}
2 changes: 2 additions & 0 deletions Domain/Entities/Appointment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
public DateTime StartTime { get; private set; }
public DateTime EndTime { get; private set; }
public AppointmentStatus Status { get; private set; }
public Guid TenantId { get; set; }
public Tenant Tenant { get; set; }

public ICollection<AppointmentServiceLink> AppointmentServices { get; private set; } = new List<AppointmentServiceLink>();

private Appointment() { } // For EF

Check warning on line 19 in Domain/Entities/Appointment.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Tenant' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 19 in Domain/Entities/Appointment.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Title' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

public Appointment(Guid userId, DateTime startTime, DateTime endTime, string title)
{
Expand Down
2 changes: 2 additions & 0 deletions Domain/Entities/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
public Guid Id { get; private set; }
public string Title { get; private set; }
public int DurationMinutes { get; private set; }
public Guid TenantId { get; set; }
public Tenant Tenant { get; set; }
public ICollection<AppointmentServiceLink> AppointmentServices { get; set; }=new List<AppointmentServiceLink>();

private Service() { }

Check warning on line 12 in Domain/Entities/Service.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Tenant' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 12 in Domain/Entities/Service.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Title' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

public Service(string title, int durationMinutes)
{
Expand Down
38 changes: 38 additions & 0 deletions Domain/Entities/Tenant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Domain.Entities;

public class Tenant
{
public Guid Id { get; set; }
public string Name { get; set; } = null!;
public DateTime DateJoined { get; set; }
public DateTime ExpireSubscriptionDate { get; set; }
public string Slug { get; set; } = null!;
public SubsciptionStatus SubscriptionStatus { get; set; }
public List<Appointment> Appointments { get; set; }
public List<Service> Services { get; set; }
public List<User> Users { get; set; }

public bool IsSubscriptionValid()
{
return SubscriptionStatus == SubsciptionStatus.Active && ExpireSubscriptionDate > DateTime.UtcNow;
}

public void ActiveSubscription() => SubscriptionStatus = SubsciptionStatus.Active;
public void DeActiveSubscription() => SubscriptionStatus = SubsciptionStatus.Inactive;
private Tenant(){}
public Tenant(string name,string slug,DateTime expireSubscriptionDate)
{
Id = Guid.NewGuid();
DateJoined = DateTime.UtcNow;
Name = name;
Slug = slug;
SubscriptionStatus = SubsciptionStatus.Active;
ExpireSubscriptionDate = expireSubscriptionDate;
}
}

public enum SubsciptionStatus
{
Active,
Inactive,
}
2 changes: 2 additions & 0 deletions Domain/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
public string? PasswordResetCodeHash { get; private set; }
public DateTime? PasswordResetCodeExpireAt { get; private set; }
public int PasswordResetAttemptsCount { get; private set; }
public Guid? TenantId { get; private set; }
public Tenant? Tenant { get; set; }
public ICollection<RefreshToken> RefreshTokens { get; private set; } = new List<RefreshToken>();
public ICollection<Appointment> Appointments { get; private set; } = new List<Appointment>();

public User()

Check warning on line 21 in Domain/Entities/User.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Password' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 21 in Domain/Entities/User.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'PhoneNumber' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 21 in Domain/Entities/User.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Email' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 21 in Domain/Entities/User.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'FullName' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
using Application.Features.AppointmentServiceLink.Interfaces;
using Application.Features.Auth.Interfaces;
using Application.Features.Service.Interfaces;
using Infrastructure.Persistance;
using Infrastructure.Persistance.Repositories;
using Application.Features.Tenant.Interfaces;
using Infrastructure.Persistence;
using Infrastructure.Persistence.Repositories;
using Infrastructure.Security;
using Infrastructure.Security.Context;
using Infrastructure.Security.Hashing;
Expand Down Expand Up @@ -34,6 +35,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi
services.AddScoped<IPasswordHasher, PasswordHasher>();
services.AddScoped<IUSerContext, UserContext>();
services.AddScoped<IVerificationCodeGenerator, VerificationCodeGenerator>();
services.AddScoped<TenantRepositoryContract, TenantRepository>();

return services;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading