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:
@@ -1,4 +1,10 @@
|
||||
namespace Govor.Data.Repositories.Exceptions;
|
||||
|
||||
public class AdditionException(string s, Exception ex)
|
||||
: Exception(s, ex);
|
||||
public class AdditionException : Exception
|
||||
{
|
||||
public AdditionException(string s, Exception ex) : base(s, ex)
|
||||
{
|
||||
}
|
||||
|
||||
public AdditionException(string s) : base(s) { }
|
||||
}
|
||||
@@ -59,6 +59,9 @@ public class InvitesRepository : IInvitesRepository
|
||||
{
|
||||
_validator.Validate(invitation);
|
||||
|
||||
if(Exist(invitation.Code))
|
||||
throw new AdditionException("Invitation with given code already exists");
|
||||
|
||||
_context.Invitations.Add(invitation);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
@@ -136,6 +139,11 @@ public class InvitesRepository : IInvitesRepository
|
||||
);
|
||||
}
|
||||
|
||||
public bool Exist(string code)
|
||||
{
|
||||
return _context.Invitations.Any(i => i.Code == code);
|
||||
}
|
||||
|
||||
public bool Exist(Guid guid)
|
||||
{
|
||||
return _context.Invitations.Any(i => i.Id == guid);
|
||||
|
||||
Reference in New Issue
Block a user