コード例 #1
0
        public JsonResult SendMail(ViewModel model)
        {
            invite      obj    = new invite();
            CMSEntities db     = new CMSEntities();
            bool        result = false;

            result = SendEmail(model.email_invite, model.email_subject, model.email_message);


            try
            {
                obj.email_invite  = model.email_invite;
                obj.email_subject = model.email_subject;
                obj.email_message = model.email_message;

                db.invites.Add(obj);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }



            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
 public InviteView(invite i)
 {
     iid         = i.iid;
     create_time = i.create_time;
     from_gid    = i.from_gid;
     to_uid      = i.to_uid;
     valid       = i.valid;
 }
コード例 #3
0
 public ActionResult RSVP(invite Invite)
 {
     if (ModelState.IsValid)
     {
         return(View("Thanks", Invite));
     }
     else
     {
         return(View());
     }
 }
コード例 #4
0
ファイル: Group.aspx.cs プロジェクト: JanKuukkanen/TeeMS
    protected void gvGroupMembers_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Add the selected member to the group
        string username = (gvGroupMembers.SelectedRow.Cells[0].Controls[0] as LinkButton).Text;
        string group_id = String.Empty;


        // Fill the group_member database table as well
        // Send an invitation to the group
        try
        {
            group_id = Request.QueryString["Group"];

            int to_add_groupid = int.Parse(group_id);

            if (group_id != String.Empty)
            {
                var usertoinvite = ctx.person.Where(p => p.username == username).FirstOrDefault();
                var invitegroup  = ctx.group.Where(g => g.group_id == to_add_groupid).FirstOrDefault();

                if (usertoinvite != null && invitegroup != null)
                {
                    invite newinvitation = new invite()
                    {
                        person         = usertoinvite,
                        group          = invitegroup,
                        invite_content = String.Format("You have been invited to group {0}, do you wish to accept?", invitegroup.name)
                    };

                    ctx.invite.Add(newinvitation);

                    ctx.SaveChanges();
                }
            }
            else
            {
                lbMessages.Text = "No Group Specified";
            }
        }
        catch (Exception ex)
        {
            lbMessages.Text = ex.Message;
        }

        if (group_id != String.Empty)
        {
            Response.Redirect(String.Format(Request.ApplicationPath + "Group.aspx?Group={0}", group_id));
        }
    }
コード例 #5
0
 public async Task<int> JoinUser(invite input)
 {
     return await db.JoinUser(input.user);
 }
コード例 #6
0
 public async Task<int> InviteUser(invite input)
 {
     return await db.InviteUser(input.user, input.id);
 }
コード例 #7
0
 public async Task<int> DeleteHouse (invite input)
 {
     return await db.DeleteHouse(input.id, input.user);
 }
コード例 #8
0
        public async Task SendInvite(Request request, Response response)
        {
            var userSession = await CheckAuth.Check(request, response, AuthLevel.TeamLeader);

            if (userSession == null)
            {
                return;
            }

            var requestJson = request.Json <SendInviteRequest>();

            //判断请求是否有效
            if (!Validation.Valid(requestJson, out string reason))
            {
                await response.BadRequest(reason);

                return;
            }

            //判断当前在允许新建组队的时间范围内
            var now = DateTime.Now;

            if (Config.Config.Options.RegDeadline > 0)
            {
                var regDeadline = UnixTimestamp.FromTimestamp(Config.Config.Options.RegDeadline);
                if (now > regDeadline)
                {
                    await response.BadRequest($"报名截止时间 ({regDeadline:yyyy-MM-dd HH:mm:ss}) 已过。");
                }
            }

            //取得该用户GID
            var groupBindDb   = DbFactory.Get <UserGroupBind>();
            var groupBindList = await groupBindDb.SelectAllFromCache();

            var groupBindItem = groupBindList.FirstOrDefault(it => it.uid == userSession.uid);

            if (groupBindItem == null)
            {
                await response.BadRequest("未确定组队?");

                return;
            }

            var gid = groupBindItem.gid;

            //取得该GID已绑定人数
            var numberOfGroup = groupBindList.Count(it => it.gid == gid);

            if (numberOfGroup >= 5)
            {
                await response.BadRequest("组队人数已满,不能发出新邀请。");

                return;
            }

            //取得目标用户信息
            var userDb   = DbFactory.Get <User>();
            var userList = await userDb.SelectAllFromCache();

            var sendToUser = userList.FirstOrDefault(it => it.username == requestJson.username);

            if (sendToUser == null)
            {
                await response.BadRequest("目标用户不存在或不是未报名用户。");

                return;
            }

            //判断目标用户是否为未报名用户
            if (sendToUser.roleid != 1)
            {
                await response.BadRequest("目标用户不存在或不是未报名用户。");

                return;
            }

            //判断用户是否已被邀请
            var inviteDb = DbFactory.Get <Invite>();
            var vlist    = await inviteDb.SimpleDb.AsQueryable()
                           .Where(it => it.from_gid == gid && it.to_uid == sendToUser.uid && it.valid == 1)
                           .ToListAsync();

            if (vlist != null && vlist.Count > 0)
            {
                await response.BadRequest("该用户已发送过邀请。");

                return;
            }


            //插入邀请信息表

            var newInvite = new invite
            {
                create_time = DateTime.Now,
                from_gid    = gid,
                to_uid      = sendToUser.uid,
                valid       = 1
            };
            await inviteDb.SimpleDb.AsInsertable(newInvite).ExecuteCommandAsync();

            await inviteDb.InvalidateCache();

            await response.OK();
        }