예제 #1
0
파일: EggController.cs 프로젝트: the404/xyz
        public ActionResult EggCreate(WheelViewModel form)
        {
            var UserId = WebSecurity.GetUserId(User.Identity.Name);
            var user = UserProfileRepository.Find(Specification<EasyWeixin.Model.UserProfile>.Eval(o => o.UserId == UserId));
            form.ResponseImageTextViewModel.ImageTextName = form.WheelTitle;
            form.ResponseImageTextViewModel.ImageTextType = 101;
            form.ResponseImageTextViewModel.UserId = WebSecurity.GetUserId(User.Identity.Name);
            form.ResponseImageTextViewModel.AddTime = DateTime.Now;
            form.UserId = WebSecurity.GetUserId(User.Identity.Name);
            form.AddDate = DateTime.Now;
            form.Mark = 2;
            if (ModelState.IsValid)
            {
                Wheel Wheel = Mapper.Map<WheelViewModel, Wheel>(form);
                Wheel.WheelStyle = "Wheel.css";
                Wheel.ResponseImageText = Mapper.Map<ResponseImageTextViewModel, ResponseImageText>(form.ResponseImageTextViewModel);

                WheelRepository.Add(Wheel);
                WheelRepository.Context.Commit();
                Wheel.ResponseImageText.Url = "http://" + Request.Url.Host + "/ActivityEgg/EggIndex?WheelID=" + Wheel.ID + "&ImageTextID=" + Wheel.ResponseImageText.ID;
                Wheel.GetURL = "http://" + Request.Url.Host + "/ActivityEgg/EggIndex?WheelID=" + Wheel.ID + "&ImageTextID=" + Wheel.ResponseImageText.ID + "&User_ID=" + user.ID;
                //for (int i = 0; i < 3; i++)
                //{
                //var Angle = GetAngle(i, 3, 5);
                WheelItem wi = new WheelItem();
                wi.WheelItemScale = 0;
                // wi.WheelItemName = GetChineseNum(i + 1) + "等奖";
                wi.WheelItemName = "一等奖";
                wi.WheelItemAward = "";
                wi.isOrder = 0;
                wi.MaxAngle = "";
                wi.MinAngle = "";
                wi.WheelID = Wheel.WheelID;
                wi.AddDate = DateTime.Now;
                WheelItemRepository.Add(wi);
                WheelItemRepository.Context.Commit();
                //}
                WheelRepository.Update(Wheel);
                WheelRepository.Context.Commit();
            }
            return Redirect("/Egg/EggIndex");
        }
예제 #2
0
        public ActionResult GiftEdit(WheelViewModel form)
        {
            if (ModelState.IsValid)
            {
                Wheel Wheel = WheelRepository.GetByKey(form.ID);
                Wheel.WheelTitle = form.WheelTitle;
                Wheel.StartDate = form.StartDate;
                Wheel.EndDate = form.EndDate;
                Wheel.WheelDesc = form.WheelDesc;
                Wheel.WheelScale = form.WheelScale;
                //by tianxiu 2014-3-13
                Wheel.EveryDayTimes = form.EveryDayTimes;

                Wheel.ResponseImageText.ImageTextName = form.WheelTitle;
                Wheel.ResponseImageText.Content = form.ResponseImageTextViewModel.Content;
                WheelRepository.Update(Wheel);
                WheelRepository.Context.Commit();
            }
            return Redirect("/Gift/GiftIndex");
        }
예제 #3
0
        public ActionResult WheelEdit(WheelViewModel form)
        {
            //todo 在这里创建图文的时候好像是不能够同时指定Content和Titile,所以为了通过验证,暂时移除
            //但是并不是最好的解决方法
            ModelState.Remove("ResponseImageTextViewModel.ImageTextName");
            if (ModelState.IsValid)
            {
                Wheel Wheel = _wheelRepository.GetByKey(form.ID);
                Wheel.WheelTitle = form.WheelTitle;
                Wheel.StartDate = form.StartDate;
                Wheel.EndDate = form.EndDate;
                Wheel.WheelDesc = form.WheelDesc;
                Wheel.WheelScale = form.WheelScale;
                //by tianxiu 2014-3-13
                Wheel.EveryDayTimes = form.EveryDayTimes;

                Wheel.ResponseImageText.ImageTextName = form.WheelTitle;
                Wheel.ResponseImageText.Content = form.ResponseImageTextViewModel.Content;
                _wheelRepository.Update(Wheel);
                _wheelRepository.Context.Commit();
                return Redirect("/Wheel/WheelIndex");
            }
            return View(form);
        }
예제 #4
0
        public ActionResult WheelCreate(WheelViewModel form)
        {
            //todo 在这里创建图文的时候好像是不能够同时指定Content和Titile,所以为了通过验证,暂时移除
            //但是并不是最好的解决方法
            ModelState.Remove("ResponseImageTextViewModel.ImageTextName");

            if (ModelState.IsValid)
            {
                var userId = WebSecurity.GetUserId(User.Identity.Name);
                var user = _userProfileRepository.Find(Specification<EasyWeixin.Model.UserProfile>.Eval(o => o.UserId == userId));
                form.ResponseImageTextViewModel.ImageTextName = form.WheelTitle;
                form.ResponseImageTextViewModel.ImageTextType = 101;
                form.ResponseImageTextViewModel.UserId = WebSecurity.GetUserId(User.Identity.Name);
                form.ResponseImageTextViewModel.AddTime = DateTime.Now;
                form.UserId = WebSecurity.GetUserId(User.Identity.Name);
                form.AddDate = DateTime.Now;
                form.Mark = 0;
                Wheel Wheel = Mapper.Map<WheelViewModel, Wheel>(form);
                Wheel.WheelStyle = "Wheel.css";
                Wheel.ResponseImageText = Mapper.Map<ResponseImageTextViewModel, ResponseImageText>(form.ResponseImageTextViewModel);

                _wheelRepository.Add(Wheel);
                _wheelRepository.Context.Commit();
                Wheel.ResponseImageText.Url = "http://" + Request.Url.Host + "/ActivityWheel/WheelIndex?WheelID=" + Wheel.ID + "&ImageTextID=" + Wheel.ResponseImageText.ID;
                Wheel.GetURL = "http://" + Request.Url.Host + "/ActivityWheel/WheelIndex?WheelID=" + Wheel.ID + "&ImageTextID=" + Wheel.ResponseImageText.ID + "&User_ID=" + user.ID;
                for (int i = 0; i < 3; i++)
                {
                    var Angle = GetAngle(i, 3, 5);
                    WheelItem wi = new WheelItem();
                    wi.WheelItemScale = i + 1;
                    wi.WheelItemName = GetChineseNum(i + 1) + "等奖";
                    wi.WheelItemAward = "";
                    wi.isOrder = i;
                    wi.MaxAngle = Angle.Split('|')[1];
                    wi.MinAngle = Angle.Split('|')[0];
                    wi.WheelID = Wheel.WheelID;
                    wi.AddDate = DateTime.Now;
                    _wheelItemRepository.Add(wi);
                    _wheelItemRepository.Context.Commit();
                }
                _wheelRepository.Update(Wheel);
                _wheelRepository.Context.Commit();
                return Redirect("/Wheel/WheelIndex");
            }
            return View(form);
        }