コード例 #1
0
        /// <summary>
        ///     更新奖品
        /// </summary>
        /// <param name="member">奖品信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult Update(PrizeView pvmodel, bool savePhoto = false)
        {
            PublicHelper.CheckArgument(pvmodel, "pvmodel");
            try
            {
                Prize dbmodel = PrizeContract.Prizes.SingleOrDefault(m => m.Id.Equals(pvmodel.Id));
                if (dbmodel == null)
                {
                    return(new OperationResult(OperationResultType.Error, string.Format("不存在要更新的Id为{0}的奖品", pvmodel.Id)));
                }

                dbmodel.Name        = pvmodel.Name;
                dbmodel.Description = pvmodel.Description;
                if (savePhoto)
                {
                    dbmodel.Photo = pvmodel.Photo;
                }
                dbmodel.UpdateDate = DateTime.Now;
                return(PrizeContract.Update(dbmodel));
            }
            catch (Exception ex)
            {
                return(new OperationResult(OperationResultType.Error, ex.Message));
            }
        }
コード例 #2
0
        public ActionResult PrizeEdit(PrizeView model)
        {
            ViewBag.IsPostBack = true;
            bool savePhoto = false;

            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
            {
                Stream photoStrem = Request.Files[0].InputStream;
                byte[] fileBytes  = StreamUtil.StreamToBytes(photoStrem);

                savePhoto   = true;
                model.Photo = StreamUtil.StreamToBytes(photoStrem);
            }

            OperationResult result = PrizeSiteContract.Update(model, savePhoto);
            string          msg    = result.Message ?? result.ResultType.ToDescription();

            if (result.ResultType == OperationResultType.Success)
            {
                TempData["Message"] = "奖品修改成功。<br /><a href='/Vip/ManagePrizes'>返回</a>奖品管理页";
                return(RedirectToAction("InfoPage"));
            }
            ViewBag.Message = msg;
            return(View(model));
        }
コード例 #3
0
        /// <summary>
        ///  发布奖品
        /// </summary>
        public ActionResult PublishPrize()
        {
            PrizeView model = new PrizeView
            {
                MemberId = this.UserId ?? 0
            };

            return(View(model));
        }
コード例 #4
0
        /// <summary>
        ///  奖品详情
        /// </summary>
        public ActionResult PrizeDetail(Guid id)
        {
            ViewBag.UserId = this.UserId ?? 0;

            Prize pmodel = PrizeContract.Prizes
                           .Where(p => p.Id.Equals(id))
                           .FirstOrDefault();
            PrizeView model = pmodel.ToSiteViewModel();

            return(View(model));
        }
コード例 #5
0
        public ActionResult PrizeEdit(Guid id)
        {
            PrizeView model = PrizeContract.Prizes
                              .Where(p => p.Id.Equals(id))
                              .Select(p => new PrizeView()
            {
                Id          = p.Id,
                Name        = p.Name,
                Description = p.Description,
                Photo       = p.Photo
            }).FirstOrDefault();

            return(View(model));
        }
コード例 #6
0
        public ActionResult PublishPrize(PrizeView model)
        {
            ViewBag.IsPostBack = true;

            if (ModelState.IsValid)
            {
                //验证码验证通过
            }
            else
            {
                //验证码验证失败
                //ModelState.AddModelError("", e.Message);
                ViewBag.Message = "验证码输入不正确";
                return(View(model));
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                ViewBag.Message = "奖品名称不能为空";
                return(View(model));
            }

            if (Request.Files.Count == 0 || Request.Files[0].ContentLength == 0)
            {
                ViewBag.Message = "请选择文件";
                return(View(model));
            }
            Stream photoStrem = Request.Files[0].InputStream;

            model.Photo = StreamUtil.StreamToBytes(photoStrem);


            if (model.MemberId == 0)
            {
                ViewBag.Message = "用户Id为0";
                return(View(model));
            }
            OperationResult result = PrizeSiteContract.Add(model);
            string          msg    = result.Message ?? result.ResultType.ToDescription();

            if (result.ResultType == OperationResultType.Success)
            {
                TempData["Message"] = "奖品发布成功。<br /><a href='/Vip/PublishPrize'>继续发布<a><br /><a href='/Vip/ManagePrizes'>奖品管理<a>";
                return(RedirectToAction("InfoPage"));
            }
            //ModelState.AddModelError("", msg);
            ViewBag.Message = msg;
            return(View(model));
        }
コード例 #7
0
    //A. this is registering the services
    //meaning all I is resolved

    //Q. can we pass params to services?

    //B.
    //the initialization issue, this should be after injection, means after awake
    private async UniTask Initialize(ActiveRoomState activeRoomState)
    {
        // Controller.I.OnAppPause += DestroyModuleGroup;

        var containerRoot = new GameObject("Room").transform;

        new RoomReferences();
        RoomReferences.I.Canvas = (await Addressables.InstantiateAsync("canvas", containerRoot))
                                  .GetComponent <Transform>();
        RoomReferences.I.Root = containerRoot;

        PrizeView.Create();

        await ChatSystem.Create();

        await Ground.Create();

        new CoreGameplay();

        new RoomUserView.Manager();

        //dependent on RoomSettings
        //this will make registering requires order, so no circular dependencies possible

        RoomUserView.Manager.I.Init();

        await CoreGameplay.I.CreatePlayers();

        Repository.I.PersonalFullInfo.Money -= RoomSettings.I.BetMoneyToPay();

        Background.I.SetForRoom(RoomSettings.I.UserInfos);

        // AssignRpcs();

        if (activeRoomState == null)
        {
            Controller.I.SendAsync("Ready").Forget(e => throw e);
        }
        else
        {
            //todo why this
            // await UniTask.DelayFrame(1);

            CoreGameplay.I.ResumeGame(activeRoomState.MyHand, activeRoomState.Ground,
                                      activeRoomState.HandCounts,
                                      activeRoomState.CurrentTurn);
        }
    }
コード例 #8
0
        public JsonResult PublishPrizeAjax(PrizeView model)
        {
            if (ModelState.IsValid)
            {
                //验证码验证通过
            }
            else
            {
                //验证码验证失败
                //ModelState.AddModelError("", e.Message);
                ViewBag.Message = "验证码输入不正确";
                return(Json(new { OK = false, Message = "验证码输入不正确" }, JsonRequestBehavior.AllowGet));
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                ViewBag.Message = "奖品名称不能为空";
                return(Json(new { OK = false, Message = "奖品名称不能为空" }, JsonRequestBehavior.AllowGet));
            }

            if (model.MemberId == 0)
            {
                ViewBag.Message = "用户Id为0";
                return(Json(new { OK = false, Message = "用户Id为0" }, JsonRequestBehavior.AllowGet));
            }
            OperationResult result = PrizeSiteContract.Add(model);

            if (result.ResultType == OperationResultType.Success)
            {
                Prize  rtnmodel = (Prize)result.AppendData;
                string pid      = string.Empty;
                if (rtnmodel != null)
                {
                    pid = rtnmodel.Id.ToString();
                }
                return(Json(new { OK = true, Message = "奖品发布成功!", PrizeId = pid }, JsonRequestBehavior.AllowGet));
            }

            string msg = result.Message ?? result.ResultType.ToDescription();

            return(Json(new { OK = false, Message = msg }, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        /// <summary>
        ///     添加奖品
        /// </summary>
        /// <param name="prizebetting">奖品信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult Add(PrizeView pvmodel)
        {
            //PublicHelper.CheckArgument(pvmodel, "pvmodel");
            Prize pmodel = new Prize
            {
                Name        = pvmodel.Name,
                Description = pvmodel.Description,
                Photo       = pvmodel.Photo,
                Member      = AccountContract.Members.SingleOrDefault(m => m.Id.Equals(pvmodel.MemberId))
            };

            try
            {
                return(PrizeContract.Add(pmodel));
            }
            catch (Exception ex)
            {
                return(new OperationResult(OperationResultType.Error, ex.Message));
            }
        }