public IActionResult SendPlaydate(ViewModelSendInvite invite)
        {
            var userId     = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var petOwnerId = _repo.PetOwner.GetPetOwnerById(userId).Id;

            ObjectCalendar objectCalendar = _repo.ObjectCalendar.GetCalenderByIdentityUser(userId);

            ObjectEvent eventCreated = new ObjectEvent();

            eventCreated.Title            = invite.Title;
            eventCreated.Date             = invite.Date;
            eventCreated.Details          = invite.Details;
            eventCreated.StartTime        = invite.StartTime;
            eventCreated.Location         = invite.Location;
            eventCreated.EndTime          = invite.EndTime;
            eventCreated.ObjectCalendarId = objectCalendar.Id;
            _repo.ObjectEvent.CreateEvent(eventCreated);
            _repo.Save();

            ObjectEvent  objectEvent = _repo.ObjectEvent.GetEventByAllProperties(invite.Title, invite.Location, invite.Details, invite.Date, invite.StartTime, invite.EndTime, objectCalendar.Id);
            ObjectInvite invitation  = new ObjectInvite();

            invitation.isInvitationAccepted = null;
            invitation.ObjectEventId        = eventCreated.Id;
            invitation.OwnerInvitedId       = invite.OwnerInvitedId;
            invitation.OwnerSendingId       = petOwnerId;
            invitation.ObjectEventId        = objectEvent.Id;
            invitation.OwnerSendingName     = invite.OwnerSendingName;
            invitation.ObjectEventName      = invite.Title;
            _repo.ObjectInvite.CreateInvite(invitation);
            _repo.Save();

            return(RedirectToAction("SearchPetProfiles"));
        }
        public IActionResult AcceptorDeclineInvite(int id)
        {
            var userId     = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var petOwnerId = _repo.PetOwner.GetPetOwnerById(userId).Id;

            ObjectInvite   invitation           = _repo.ObjectInvite.FindByCondition(i => i.Id == id).FirstOrDefault();
            ObjectEvent    objectEvent          = _repo.ObjectEvent.GetEventById(invitation.ObjectEventId);
            ObjectCalendar invitedOwnerCalendar = _repo.ObjectCalendar.GetCalenderByIdentityUser(userId);

            if (!invitation.isInvitationAccepted.HasValue)
            {
                invitation.isInvitationAccepted = true;

                ObjectEvent newEvent = new ObjectEvent();
                newEvent.Title            = objectEvent.Title;
                newEvent.Location         = objectEvent.Location;
                newEvent.Details          = objectEvent.Details;
                newEvent.Date             = objectEvent.Date;
                newEvent.StartTime        = objectEvent.StartTime;
                newEvent.EndTime          = objectEvent.EndTime;
                newEvent.ObjectCalendarId = invitedOwnerCalendar.Id;
                _repo.ObjectEvent.CreateEvent(newEvent);
                _repo.Save();

                invitation.ObjectEvent          = objectEvent;
                invitation.isInvitationAccepted = true;
                _repo.ObjectInvite.Update(invitation);
                _repo.Save();
            }
            else if (invitation.isInvitationAccepted.Value == true)
            {
                invitation.ObjectEvent          = objectEvent;
                invitation.isInvitationAccepted = false;
                _repo.ObjectInvite.Update(invitation);
                _repo.Save();
            }
            else
            {
                invitation.ObjectEvent          = objectEvent;
                invitation.isInvitationAccepted = null;
                _repo.ObjectInvite.Update(invitation);
                _repo.Save();
            }

            return(RedirectToAction(nameof(DisplayInvites), id));
        }