Ejemplo n.º 1
0
 public ActionResult VoteCreate(VoteViewModel 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.VoteTitle;
     form.ResponseImageTextViewModel.ImageTextType = 105;
     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)
     {
         Vote Vote = Mapper.Map<VoteViewModel, Vote>(form);
         Vote.VoteStyle = "Vote.css";
         Vote.ResponseImageText = Mapper.Map<ResponseImageTextViewModel, ResponseImageText>(form.ResponseImageTextViewModel);
         VoteRepository.Add(Vote);
         VoteRepository.Context.Commit();
         Vote.ResponseImageText.Url = "http://" + Request.Url.Host + "/Activity/VoteIndex?VoteID=" + Vote.ID + "&ImageTextID=" + Vote.ResponseImageText.ID;
         Vote.GetURL = "http://" + Request.Url.Host + "/Activity/VoteIndex?VoteID=" + Vote.ID + "&ImageTextID=" + Vote.ResponseImageText.ID + "&User_ID=" + user.ID;
         VoteRepository.Update(Vote);
         VoteRepository.Context.Commit();
     }
     return Redirect("/Vote/VoteIndex");
 }
Ejemplo n.º 2
0
 public ActionResult VoteEdit(VoteViewModel form)
 {
     if (ModelState.IsValid)
     {
         Vote Vote = VoteRepository.GetByKey(form.ID);
         Vote.VoteTitle = form.VoteTitle;
         Vote.StartDate = form.StartDate;
         Vote.EndDate = form.EndDate;
         Vote.VoteDesc = form.VoteDesc;
         Vote.VoteAnswer = form.VoteAnswer;
         Vote.VoteType = form.VoteType;
         Vote.ResponseImageText.ImageTextName = form.VoteTitle;
         Vote.ResponseImageText.Content = form.ResponseImageTextViewModel.Content;
         VoteRepository.Update(Vote);
         VoteRepository.Context.Commit();
     }
     return Redirect("/Vote/VoteIndex");
 }