public ActionResult Create(Vegetable vegetable) { ReturnObj returnObj = new ReturnObj(); if (iGenericRepository.GetById(vegetable.ScBh) == null) { if (iGenericRepository.Save(vegetable) > 0) { returnObj.State = 1; returnObj.Msg = "保存成功!"; } else { returnObj.State = -1; returnObj.Msg = "保存失败!"; } } else { returnObj.State = -1; returnObj.Msg = "已存在"; } return RedirectToAction("Index"); }
public ActionResult Edit(Vegetable vegetable) { var mode = iGenericRepository.Update(vegetable); return RedirectToAction("Index"); }
/// <summary> /// 用于向 Vegetables EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToVegetables(Vegetable vegetable) { base.AddObject("Vegetables", vegetable); }
/// <summary> /// 创建新的 Vegetable 对象。 /// </summary> /// <param name="scBh">ScBh 属性的初始值。</param> /// <param name="scName">ScName 属性的初始值。</param> public static Vegetable CreateVegetable(global::System.String scBh, global::System.String scName) { Vegetable vegetable = new Vegetable(); vegetable.ScBh = scBh; vegetable.ScName = scName; return vegetable; }