예제 #1
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));
        }
예제 #2
0
        /// <summary>
        ///  删除奖品
        /// </summary>
        /// <param name="id"></param>
        public ActionResult PrizeDelete(Guid id)
        {
            OperationResult result = PrizeSiteContract.Delete(id);
            string          msg    = result.Message ?? result.ResultType.ToDescription();

            if (result.ResultType == OperationResultType.Success)
            {
                TempData["Message"] = "奖品删除成功。<br /><a href='/Vip/ManagePrizes'>返回</a>奖品管理页";
                return(RedirectToAction("InfoPage"));
            }
            TempData["Message"] = msg;
            return(RedirectToAction("ManagePrizes"));
        }
예제 #3
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));
        }
예제 #4
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));
        }