Example #1
0
        //执行添加操作
        public bool ExectudeQuit(int clubID)
        {
            int userID = Common.User.GetUserID(Session["Username"].ToString());

            //回传给前台view的model
            var bll = new BLL.newMember();
            //判断是否提交了社团的申请且申请未通过审核
            //state为0表示暂未审核
            bool hasApply = bll.Exist(p => (p.userID == userID & p.clubID == clubID & p.state == 0));

            if (hasApply)
            {
                //删除记录
                var model = bll.GetModel(p => (p.userID == userID & p.clubID == clubID & p.state == 0));
                bll.Delete(model, false);
                ViewBag.NewClubs = bll.GetRecordCount(p => (p.userID == userID & p.state == 0));;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        //执行添加操作
        public AddClub exectudeAdd(int id)
        {
            var bll    = new BLL.newMember();
            int userid = Common.User.GetUserID(Session["Username"].ToString());
            var model  = new Model.newmember()
            {
                userID = userid,
                clubID = id,
                time   = DateTime.Now,
                state  = 0
            };

            //回传给前台view的model
            //通过设置默认值为true,可精简代码
            var viewModel = new AddClub()
            {
                HasJoined = true, HasApply = true
            };
            //判断是否加入了社团
            bool hasJoind = new BLL.clubMember().Exist(p => (p.userid == userid & p.clubid == id));

            if (!hasJoind)
            {
                viewModel.HasJoined = false;
                //未加入社团时才判断是否申请过并没有被审核
                //判断是否申请了社团
                bool hasApply = bll.Exist(p => (p.userID == userid & p.clubID == id & p.state == 0));
                if (!hasApply)
                {
                    viewModel.HasApply = false;
                    viewModel.HasRun   = true;
                    bll.Add(model);
                }
            }
            return(viewModel);
        }