/// <summary> /// 创建新的 PrizeCategory 对象。 /// </summary> /// <param name="id">Id 属性的初始值。</param> /// <param name="name">Name 属性的初始值。</param> public static PrizeCategory CreatePrizeCategory(global::System.Int32 id, global::System.String name) { PrizeCategory prizeCategory = new PrizeCategory(); prizeCategory.Id = id; prizeCategory.Name = name; return prizeCategory; }
public ActionResult AddPrizeCategory(PrizeCatValidation pcv) { if (ModelState.IsValid) { PrizeCategory pc = _uow.PrizeCategoryService.Get(o => o.Name == pcv.Name); if (pc == null) { pc = new PrizeCategory(); pc.Name = pcv.Name; _uow.PrizeCategoryService.Add(pc); _uow.Commit(); return RedirectToAction("PrizeCategory"); } ModelState.AddModelError("", "类别已存在"); return View(); } return View(); }
/// <summary> /// 用于向 PrizeCategory EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToPrizeCategory(PrizeCategory prizeCategory) { base.AddObject("PrizeCategory", prizeCategory); }