Beispiel #1
0
        public async Task <ActionResult <GroupInviteLink> > AddGroupInviteLink(int id)
        {
            var user = await _utils.GetUserAsync(User);

            if (user.GroupUsers.All(t => t.GroupId != id))
            {
                return(Forbid());
            }

            var groupInviteLink = new GroupInviteLink
            {
                Expires    = DateTime.UtcNow + TimeSpan.FromHours(1),
                GroupId    = id,
                InviteCode = Guid.NewGuid().ToString().Replace("-", "").Replace("{", "").Replace("}", "")
            };

            var b = new Guid().ToString();

            _context.GroupInviteLink.Add(groupInviteLink);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGroupInviteLink",
                                   new
            {
                id = groupInviteLink.GroupInviteLinkId,
                inviteCode = groupInviteLink.InviteCode
            }, groupInviteLink));
        }
Beispiel #2
0
        /// <inheritdoc />
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = GroupInviteLink != null?GroupInviteLink.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ IsGroup.GetHashCode();
                hashCode = (hashCode * 397) ^ (Participants != null ? Participants.GetHashCode() : 0);
                return(hashCode);
            }
        }