Exemplo n.º 1
0
 public ActionResult GuessEdit(GuessViewModel form)
 {
     if (ModelState.IsValid)
     {
         Guess guess = GuessRepository.GetByKey(form.ID);
         guess.GuessTitle = form.GuessTitle;
         guess.StartDate = form.StartDate;
         guess.EndDate = form.EndDate;
         guess.GuessDesc = form.GuessDesc;
         guess.ResponseImageText.ImageTextName = form.GuessTitle;
         guess.ResponseImageText.Content = form.ResponseImageTextViewModel.Content;
         GuessRepository.Update(guess);
         GuessRepository.Context.Commit();
     }
     return View(form);
 }
Exemplo n.º 2
0
        public ActionResult GuessCreate(GuessViewModel 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.GuessTitle;
            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;
            if (ModelState.IsValid)
            {
                Guess guess = Mapper.Map<GuessViewModel, Guess>(form);
                guess.GuessStyle = "GuessNews.css";
                guess.ResponseImageText = Mapper.Map<ResponseImageTextViewModel, ResponseImageText>(form.ResponseImageTextViewModel);
                GuessRepository.Add(guess);
                GuessRepository.Context.Commit();
                guess.ResponseImageText.Url = "http://" + Request.Url.Host + "/News/GuessNews?ImageTextID=" + guess.ResponseImageText.ID;
                guess.GetURL = "http://" + Request.Url.Host + "/News/GuessNews?ImageTextID=" + guess.ResponseImageText.ID + "&User_ID=" + user.ID;
                GuessRepository.Update(guess);
                GuessRepository.Context.Commit();
            }
            return View(form);
        }