/// <summary> /// Deprecated Method for adding a new object to the PackageItems EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPackageItems(PackageItems packageItems) { base.AddObject("PackageItems", packageItems); }
public ActionResult AddItemsPackage(ItemsPackage package) { package.CreateTime = DateTime.Now; DBContext.ItemsPackage.AddObject(package); DBContext.SaveChanges(); if (Request.Form["itemid"] != null && Request.Form["listid"] != null) { string[] items = Request.Form["itemid"].Split(','); string[] listids = Request.Form["listid"].Split(','); for (int i = 0; i < items.Length; i++) { if (items[i] != string.Empty && listids[i] != string.Empty) { PackageItems ir = new PackageItems { ItemId = int.Parse(items[i]), PackageId = package.Id, ListId = int.Parse(listids[i]) }; DBContext.AddToPackageItems(ir); } } DBContext.SaveChanges(); } return RedirectToAction("IndexItemsPackage"); }
/// <summary> /// Create a new PackageItems object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="packageId">Initial value of the PackageId property.</param> /// <param name="itemId">Initial value of the ItemId property.</param> /// <param name="listId">Initial value of the ListId property.</param> public static PackageItems CreatePackageItems(global::System.Int32 id, global::System.Int32 packageId, global::System.Int32 itemId, global::System.Int32 listId) { PackageItems packageItems = new PackageItems(); packageItems.Id = id; packageItems.PackageId = packageId; packageItems.ItemId = itemId; packageItems.ListId = listId; return packageItems; }
public ActionResult EditItemsPackage(ItemsPackage package) { var obj = DBContext.ItemsPackage.FirstOrDefault(e => e.Id == package.Id); obj.Name = package.Name; obj.Remark = package.Remark; var list = DBContext.PackageItems.Where(e => e.PackageId == package.Id); foreach (var v in list) DBContext.DeleteObject(v); if (Request.Form["itemid"] != null && Request.Form["listid"] != null) { string[] items = Request.Form["itemid"].Split(','); string[] listids = Request.Form["listid"].Split(','); for (int i = 0; i < items.Length; i++) { if (items[i] != string.Empty && listids[i] != string.Empty) { PackageItems ir = new PackageItems { ItemId = int.Parse(items[i]), PackageId = package.Id, ListId = int.Parse(listids[i]) }; DBContext.AddToPackageItems(ir); } } } DBContext.SaveChanges(); return RedirectToAction("IndexItemsPackage"); }