コード例 #1
0
        public JsonResult SubmitCreation()
        {
            if (!Permission.PremissionNeed(Request, Response, Session, UserRank.TEACHER))
            {
                return(Json(0));
            }

            string groupName = Request["groupname"];
            bool   allowJoin = Convert.ToBoolean(Request["allowjoin"]);
            bool   allowquit = Convert.ToBoolean(Request["allowquit"]);
            User   user      = (User)Session["user"];

            Group group = new Group
            {
                group_name = groupName,
                owner_uid  = user.uid,
                number     = 0,
                allow_join = allowJoin,
                allow_quit = allowquit
            };

            if (!GroupView.NewGroup(group))
            {
                return(Json(0));
            }

            groupsCache = GroupView.GetAllGroups();

            GroupMember member = new GroupMember
            {
                gid  = group.gid,
                uid  = user.uid,
                rank = (int)MemberRank.CREATOR
            };

            GroupView.AddMember(group.gid, member);

            return(Json(group.gid));
        }