public JsonResult GiftItemEdit(WheelItem form) { if (form.WheelItemID == 0) { form.AddDate = DateTime.Now; // form.ImageUrl = imageurl(form.WheelItemName); WheelItemRepository.Add(form); WheelItemRepository.Context.Commit(); return Json(form); } else { var WheelItem = WheelItemRepository.Find(Specification<WheelItem>.Eval(o => o.WheelItemID == form.WheelItemID)); WheelItem.WheelItemAward = form.WheelItemAward; WheelItem.WheelItemName = form.WheelItemName; WheelItem.WheelItemScale = form.WheelItemScale; WheelItemRepository.Update(WheelItem); WheelItemRepository.Context.Commit(); return Json(WheelItem); } }
public ActionResult GiftCreate(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 = 1; 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 + "/ActivityGift/GiftIndex?WheelID=" + Wheel.ID + "&ImageTextID=" + Wheel.ResponseImageText.ID; Wheel.GetURL = "http://" + Request.Url.Host + "/ActivityGift/GiftIndex?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.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("/Gift/GiftIndex"); }
public ActionResult GiftItemEdit(int WheelID, Guid? ID = null) { if (ID == null) { WheelItem Wheelitem = new WheelItem(); Wheelitem.WheelID = WheelID; return View(Wheelitem); } else { var Wheelitem = WheelItemRepository.GetByKey(ID); return View(Wheelitem); } }
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); }