Exemplo n.º 1
0
 public async Task <IActionResult> AddInvitation(AddInvitation invitation)
 {
     if (await _service.AddInvitation(invitation))
     {
         return(Ok(new { status = "OK", message = "Poprawnie wysłano zaproszenie!" }));
     }
     return(Ok(new { status = "Exists", message = "Wysłałeś już takie zaproszenie!" }));
 }
Exemplo n.º 2
0
 public Invitation(AddInvitation invitation)
 {
     EventId     = invitation.EventId;
     SenderId    = invitation.UserIdSender;
     RecipientId = invitation.UserIdRept;
     IsNew       = true;
     IsAccepted  = false;
     Type        = invitation.InvitationType;
 }
Exemplo n.º 3
0
        private async Task <bool> ChechIsExists(AddInvitation addInvitation)
        {
            int isExists = await _context.Invitations.CountAsync(x =>
                                                                 (x.SenderId == addInvitation.UserIdSender) &&
                                                                 (x.RecipientId == addInvitation.UserIdRept) &&
                                                                 (addInvitation.EventId == x.EventId));

            if (isExists == 0)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        public async Task <bool> AddInvitation(AddInvitation invitation)
        {
            Invitation dbInvi = new Invitation(invitation);

            if (!await ChechIsExists(invitation))
            {
                _context.Invitations.Add(dbInvi);
                await _context.SaveChangesAsync();

                return(true);
            }
            return(false);
        }