예제 #1
0
        /// <summary>
        /// 添加活动
        /// </summary>
        /// <returns></returns>
        public ActionResult AddActivityOperator(Activity activity, List <ActivityAward> activityAwards)
        {
            bool result;

            if (activity.Id <= 0)
            {
                result = _activityRespository.AddActivity(activity, activityAwards);
                return(Json(new DataResult()
                {
                    Status = result,
                    Notify = result ? "操作成功" : "操作失败"
                }));
            }
            //1.判断签到数量和签到限制数量
            var currentActivity = _activityRespository.Get(DbConfig.DbConnStr, activity.Id);

            if (currentActivity.SignInNumber > activity.LimitNumber)
            {
                return(Json(new DataResult()
                {
                    Status = false,
                    Notify = "签到数量不能大于签到限制数量"
                }));
            }
            //2.修改
            result = _activityRespository.EditActivity(activity, activityAwards);
            return(Json(new DataResult()
            {
                Status = activity != null,
                Notify = activity != null ? "操作成功" : "操作失败"
            }));
        }
예제 #2
0
        // GET: Home/Home
        public ActionResult Index(int activityId)
        {
            var model = AppUtil.GetCurrentUser <ScreenAuthDto>(Application.Enum.TokenTypeEnum.Screen_Auth);

            if (model != null && model.ActivityId == activityId)
            {
                return(RedirectToAction("SigninScreen", "Screen", new { activityId }));
            }
            var currentActivity = _activityRespository.Get(DbConfig.DbConnStr, activityId);

            ViewBag.data = JsonHelper.Set(currentActivity);
            return(View());
        }
예제 #3
0
        /// <summary>
        /// 签到视图
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public ActionResult Signin(int activityId)
        {
            var currentSignInAuth        = AppUtil.GetCurrentUser <SignInAuthDto>(TokenTypeEnum.SignIn_Auth);
            var weixinAuthUserInfoResult = _weixinRespository.GetUserInfoByOpennIdAndAccessToken(currentSignInAuth.Access_Token, currentSignInAuth.OpenId);
            var record = _signInService.SignInRecord(activityId, weixinAuthUserInfoResult);
            //获取当前活动数据
            var currentActivity = _activityRespository.Get(DbConfig.DbConnStr, activityId);

            ViewBag.data = JsonHelper.Set(new
            {
                record,
                weixinAuthUserInfoResult,
                activity = currentActivity
            });
            return(View());
        }
예제 #4
0
        /// <summary>
        /// 签到业务
        /// </summary>
        /// <param name="record"></param>
        /// <param name="notify"></param>
        /// <returns></returns>
        public bool SignIn(SignInRecord record, out string notify)
        {
            //1.判断是否超出报名限制
            var currentActivity = _activityRespository.Get(DbConfig.DbConnStr, record.ActivityId);

            if (currentActivity == null || currentActivity.Id <= 0)
            {
                notify = "不存在当前活动";
                return(false);
            }
            if (currentActivity.Status == Core.Enum.ActivityStatusEnum.End)
            {
                notify = "活动已停止报名";
                return(false);
            }
            if (currentActivity.SignInNumber >= currentActivity.LimitNumber)
            {
                notify = "报名已满";
                return(false);
            }
            //2.判断是否签到
            if (_sigInRecordRespository.CheckSignIn(record.OpenId, record.ActivityId))
            {
                notify = "您已经签到过";
                return(false);
            }
            //3.签到
            record.Id         = Guid.NewGuid().ToString("N");
            record.CreateTime = DateTime.Now;
            bool result = _sigInRecordRespository.SignIn(record);

            if (!result)
            {
                notify = "签到失败";
                return(true);
            }
            notify = "签到成功";
            return(true);
        }