Esempio n. 1
0
        /// <summary>
        /// 用户提交数据
        /// </summary>
        /// <param name="WheelUser">金蛋玩家实体,实体中只传递过来玩家的手机号码</param>
        /// <returns></returns>
        public JsonResult EggAdd(WheelUser WheelUser)
        {
            if (Session["WheelCode"] != null)
            {
                var WheelCode = (WheelLog)Session["WheelCode"];
                var Wheel = WheelRepository.Find(Specification<Wheel>.Eval(o => o.WheelID == WheelCode.WheelID));

                //循环判断是否已存在相同的手机号码,同样的微信号
                var users = WheelUserRepository.FindAll(Specification<WheelUser>.Eval(o => o.WheelID == Wheel.WheelID)).ToList();
                foreach (var item in users)
                {
                    if (item.WheelUserWexinID.Equals(WheelUser.WheelUserWexinID))
                    {
                        return Json(new { message = "每个ID最多可赢一张欢乐谷门票!" });
                    }
                }

                var ip = Request.UserHostAddress;
                var dt = DateTime.Now.Date;
                WheelUser.WheelItemID = Wheel.WheelItems.ToList()[WheelCode.IsAward - 1].WheelItemID;
                WheelUser.WheelID = WheelCode.WheelID;
                WheelUser.IP = Request.UserHostAddress;
                WheelUser.WheelCode = WheelCode.WheelCode;
                WheelUser.UserId = int.Parse(Session["UserId"].ToString());
                WheelUser.AddDate = DateTime.Now;
                WheelUser.WheelLogID = WheelCode.WheelLogID;
                WheelUser.WheelUserWexinID = Session["openId"].ToString();
                WheelUserRepository.Add(WheelUser);
                WheelUserRepository.Context.Commit();
                Session["WheelCode"] = null;
                Session["openId"] = null;
                return Json(new { message = "提交成功" });
            }
            else
            {
                return Json(new { message = "已超时!" });
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 用户提交数据
        /// </summary>
        /// <param name="WheelUser">大转盘玩家实体,实体中只传递过来玩家的手机号码</param>
        /// <returns></returns>
        public JsonResult WheelAdd(WheelUser WheelUser)
        {
            if (Session["WheelCode"] != null)
            {
                var WheelCode = (WheelLog)Session["WheelCode"];
                var Wheel = WheelRepository.Find(Specification<Wheel>.Eval(o => o.WheelID == WheelCode.WheelID));

                //循环判断是否已存在相同的手机号码
                var users = WheelUserRepository.FindAll(Specification<WheelUser>.Eval(o => o.WheelID == Wheel.WheelID)).ToList();
                foreach (var item in users)
                {
                    if (item.WheelUserPhone.Equals(WheelUser.WheelUserPhone))
                    {
                        return Json(new { message = "您提交的手机号码已经中过奖了!" });
                    }
                }

                //var log = WheelLogRepository.FindAll(Specification<WheelLog>.Eval(o => o.WheelID == Wheel.WheelID)).ToList();

                //foreach (var m in log)
                //{
                //    var wheelusers = WheelUserRepository.FindAll(Specification<WheelUser>.Eval(o => o.WheelID == Wheel.WheelID && o.WheelLogID == m.WheelLogID)).ToList();
                //    if (wheelusers.FirstOrDefault() == null)
                //    {
                //        //删除因为输入相同手机号码录入的日志信息
                //        WheelLogRepository.Remove(m);
                //        WheelLogRepository.Context.Commit();
                //    }

                //}

                var ip = Request.UserHostAddress;
                var dt = DateTime.Now.Date;
                WheelUser.WheelItemID = Wheel.WheelItems.ToList()[WheelCode.IsAward - 1].WheelItemID;
                WheelUser.WheelID = WheelCode.WheelID;
                WheelUser.IP = Request.UserHostAddress;
                WheelUser.WheelCode = WheelCode.WheelCode;
                WheelUser.UserId = int.Parse(Session["UserId"].ToString());
                WheelUser.AddDate = DateTime.Now;
                WheelUser.WheelLogID = WheelCode.WheelLogID;
                WheelUserRepository.Add(WheelUser);
                WheelUserRepository.Context.Commit();
                Session["WheelCode"] = null;
                return Json(new { message = "提交成功" });
            }
            else
            {
                return Json(new { message = "已超时!" });
            }
        }