Esempio n. 1
0
        public JsonResult CouponItemEdit(CouponItem form)
        {
            if (form.CouponItemID == 0)
            {
                form.AddDate = DateTime.Now;
                CouponItemRepository.Add(form);
                CouponItemRepository.Context.Commit();
                return Json(form);
            }
            else
            {
                var CouponItem = CouponItemRepository.Find(Specification<CouponItem>.Eval(o => o.CouponItemID == form.CouponItemID));
                CouponItem.CouponItemAward = form.CouponItemAward;
                CouponItem.CouponItemName = form.CouponItemName;

                CouponItem.CouponItemScale = form.CouponItemScale;
                CouponItemRepository.Update(CouponItem);
                CouponItemRepository.Context.Commit();
                return Json(CouponItem);
            }
        }
Esempio n. 2
0
 public ActionResult CouponItemIndex(int CouponID)
 {
     var Coupon = CouponRepository.Find(Specification<Coupon>.Eval(o => o.CouponID == CouponID));
     List<CouponItem> CouponItemList = Coupon.CouponItems.ToList();
     if (CouponItemList.Count == 0)
     {
         for (int i = 0; i < 3; i++)
         {
             CouponItem ci = new CouponItem();
             ci.CouponItemScale = i + 1;
             ci.CouponItemName = (i + 1).ToString() + "等奖";
             ci.CouponItemAward = "";
             ci.CouponID = Coupon.CouponID;
             ci.AddDate = DateTime.Now;
             CouponItemRepository.Add(ci);
             CouponItemRepository.Context.Commit();
         }
     }
     return View(CouponItemList);
 }
Esempio n. 3
0
 public ActionResult CouponItemEdit(int CouponID, Guid? ID = null)
 {
     if (ID == null)
     {
         CouponItem Couponitem = new CouponItem();
         Couponitem.CouponID = CouponID;
         return View(Couponitem);
     }
     else
     {
         var Couponitem = CouponItemRepository.GetByKey(ID);
         return View(Couponitem);
     }
 }