Example #1
0
 public ActionResult FightCreate(FightViewModel 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.FightTitle;
     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)
     {
         Fight Fight = Mapper.Map<FightViewModel, Fight>(form);
         Fight.FightStyle = "Fight.css";
         Fight.ResponseImageText = Mapper.Map<ResponseImageTextViewModel, ResponseImageText>(form.ResponseImageTextViewModel);
         FightRepository.Add(Fight);
         FightRepository.Context.Commit();
         Fight.ResponseImageText.Url = "http://" + Request.Url.Host + "/Activity/FightIndex?FightID=" + Fight.ID + "&ImageTextID=" + Fight.ResponseImageText.ID;
         Fight.GetURL = "http://" + Request.Url.Host + "/Activity/FightIndex?FightID=" + Fight.ID + "&ImageTextID=" + Fight.ResponseImageText.ID + "&User_ID=" + user.ID;
         FightRepository.Update(Fight);
         FightRepository.Context.Commit();
     }
     return Redirect("/Fight/FightIndex");
 }
Example #2
0
        public ActionResult FightEdit(FightViewModel form)
        {
            if (ModelState.IsValid)
            {
                Fight Fight = FightRepository.GetByKey(form.ID);
                Fight.FightTitle = form.FightTitle;
                Fight.StartDate = form.StartDate;
                Fight.EndDate = form.EndDate;
                Fight.FightDesc = form.FightDesc;

                Fight.ResponseImageText.ImageTextName = form.FightTitle;
                Fight.ResponseImageText.Content = form.ResponseImageTextViewModel.Content;
                FightRepository.Update(Fight);
                FightRepository.Context.Commit();
            }
            return Redirect("/Fight/FightIndex");
        }