Invitation globale work

+ tests
+ new services
+ InvitationDto and IInvitationReqest
This commit is contained in:
Artemy
2025-06-24 21:20:43 +07:00
parent f99ec0b17b
commit 76094af15b
38 changed files with 483 additions and 1640 deletions
+13
View File
@@ -0,0 +1,13 @@
namespace Govor.Core.DTOs;
public class InvitationDto
{
public Guid Id { get; set; }
public bool IsAdmin { get; set; }
public bool IsActive { get; set; }
public string Code {get; set;}
public DateTime CreatedAt { get; set; }
public DateTime EndAt { get; set; }
public int MaxParticipants { get; set; }
public string Description { get; set; }
}
@@ -15,10 +15,10 @@ public class InvitationValidator : IObjectValidator<Invitation>
throw new ArgumentException("Id cannot be empty", nameof(inv.Id));
if(inv.DateCreated == DateTime.MinValue)
throw new ArgumentException("DateCreated cannot be empty", nameof(inv.DateCreated));
if(inv.EndDate < inv.DateCreated)
throw new ArgumentException("EndDate cannot be less than StartDate", nameof(inv.EndDate));
if(inv.MaxParticipants <= 0)
throw new ArgumentException("MaxParticipants cannot be less than 0", nameof(inv.MaxParticipants));
if(inv.EndDate < inv.DateCreated && inv.IsActive)
throw new ArgumentException("EndDate cannot be less than StartDate when is active", nameof(inv.EndDate));
if((inv.MaxParticipants <= 0 || inv.MaxParticipants <= inv.Users.Count) && inv.IsActive)
throw new ArgumentException("MaxParticipants cannot be less than 0 or users cannot be more then MaxParticipants when is active", nameof(inv.MaxParticipants));
if(inv.Code == string.Empty || inv.Code.Length < MIN_INVITATION_LENGTH)
throw new ArgumentException($"Code cannot be empty or less then {MIN_INVITATION_LENGTH}", nameof(inv.Code));
}
+1
View File
@@ -4,6 +4,7 @@ public class Invitation
{
public Guid Id { get; set; }
public bool IsAdmin { get; set; }
public bool IsActive { get; set; } = true;
public string Code { get; set; }
public string Description { get; set; }
public DateTime DateCreated { get; set; }
@@ -5,5 +5,6 @@ namespace Govor.Core.Repositories.Invaites;
public interface IInvitesExist
{
bool Exist(Invitation invitation);
bool Exist(string code);
bool Exist(Guid guid);
}
@@ -0,0 +1,9 @@
namespace Govor.Core.Requests;
public class CreateInvitationRequest
{
public DateTime EndDate { get; set; }
public int MaxParticipants { get; set; }
public bool IsAdmin { get; set; }
public string Description { get; set; }
}