mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Invitation globale work
+ tests + new services + InvitationDto and IInvitationReqest
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
Reference in New Issue
Block a user