public void InviteUser(string summonerName, string summonerId)
        {
            Int64        intId  = Int64.Parse(summonerId);
            CreateInvite invite = new CreateInvite();

            invite.toSummonerId   = intId;
            invite.toSummonerName = summonerName;
            LobbyOwner            = true;

            Task.Run(() =>
            {
                var resp = SendApiRequest("POST", "lol-lobby/v2/lobby/invitations", new CreateInvite[] { invite });
                if (resp.StatusCode != HttpStatusCode.OK)
                {
                    Console.WriteLine(resp.StatusDescription);
                }
                resp.Close();
            });
        }
예제 #2
0
        public ActionResult SendInvite([Bind(Include = "InstanceID,Recipient")] CreateInvite invite, int InstanceID)
        {
            if (ModelState.IsValid)
            {
                if (manager.FindByEmail(invite.Recipient) == null)
                {
                    ModelState.AddModelError("Recipient", "Not a valid user");
                }

                if (invite.Recipient == Generic.GetUserName())
                {
                    ModelState.AddModelError("Recipient", "Cannot invite yourself");
                }

                //now see if another invite already exists for this instance and user and is active.
                var existing = db.Invites.Any(x => x.Accepted == null && x.Active && x.Recipient == invite.Recipient && x.InstanceID == invite.InstanceID);
                if (existing)
                {
                    ModelState.AddModelError("Recipient", "User has a pending invite.");
                }

                //and of course, confirm that user doesn't already exist in the instance.
                existing = db.Members.Any(x => x.InstanceID == invite.InstanceID && x.UserName == invite.Recipient);
                if (existing)
                {
                    ModelState.AddModelError("Recipient", "User is already a member.");
                }

                if (ModelState.IsValid)
                {
                    var newInvite = new Invite(invite);
                    db.Invites.Add(newInvite);
                    db.SaveChanges();
                    return(Json(new { refresh = true }));
                }
            }
            return(Json(new { error = Generic.GetValidationErrors(ModelState) }));
        }
예제 #3
0
        public static async Task <Invite> CreateInvite(string chnId, CreateInvite invite)
        {
            IChannelService channelservice = AuthenticatedRestFactory.GetChannelService();

            return(await channelservice.CreateChannelInvite(chnId, invite));
        }
예제 #4
0
        /// <inheritdoc />
        public virtual Task <SharedModels.Invite> CreateChannelInvite(string channelid, CreateInvite invite)
        {
            var arguments = new object[] { channelid, invite };

            return((Task <SharedModels.Invite>)methodImpls["CreateChannelInvite"](Client, arguments));
        }