/// <summary> /// 用于向 Prize EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToPrize(Prize prize) { base.AddObject("Prize", prize); }
public ActionResult AddPrize(Prize newPrize) { if (newPrize.Id == 0) { newPrize.IsEnabled = true; int catID = newPrize.CategoryId; Prize old_pz = _uow.PrizeService.Get(o => o.CategoryId == catID && o.Name == newPrize.Name); ViewData["CatList"] = GetCatList(); if (old_pz != null) { ModelState.AddModelError("", "奖品已存在"); return View(); } _uow.PrizeService.Add(newPrize); } else { var oldPz = _uow.PrizeService.Get(t => t.Id == newPrize.Id); oldPz.CategoryId = newPrize.CategoryId; oldPz.Name = newPrize.Name; oldPz.ImgUrl = newPrize.ImgUrl; oldPz.PrizeCount = newPrize.PrizeCount; oldPz.Probability = newPrize.Probability; oldPz.Angle = newPrize.Angle; oldPz.IsEnabled = newPrize.IsEnabled; oldPz.IsVirtual = newPrize.IsVirtual; oldPz.FreeCardType = newPrize.FreeCardType; } _uow.Commit(); return RedirectToAction("Prize"); }
/// <summary> /// 创建新的 Prize 对象。 /// </summary> /// <param name="id">Id 属性的初始值。</param> /// <param name="categoryId">CategoryId 属性的初始值。</param> /// <param name="name">Name 属性的初始值。</param> /// <param name="prizeCount">PrizeCount 属性的初始值。</param> /// <param name="usedCount">UsedCount 属性的初始值。</param> /// <param name="probability">Probability 属性的初始值。</param> /// <param name="angle">Angle 属性的初始值。</param> /// <param name="isEnabled">IsEnabled 属性的初始值。</param> /// <param name="isVirtual">IsVirtual 属性的初始值。</param> public static Prize CreatePrize(global::System.Int64 id, global::System.Int32 categoryId, global::System.String name, global::System.Int32 prizeCount, global::System.Int32 usedCount, global::System.Int32 probability, global::System.Int32 angle, global::System.Boolean isEnabled, global::System.Boolean isVirtual) { Prize prize = new Prize(); prize.Id = id; prize.CategoryId = categoryId; prize.Name = name; prize.PrizeCount = prizeCount; prize.UsedCount = usedCount; prize.Probability = probability; prize.Angle = angle; prize.IsEnabled = isEnabled; prize.IsVirtual = isVirtual; return prize; }