/// <summary>
 /// Deprecated Method for adding a new object to the ItemsPackage EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToItemsPackage(ItemsPackage itemsPackage)
 {
     base.AddObject("ItemsPackage", itemsPackage);
 }
Ejemplo n.º 2
0
        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 ItemsPackage object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="remark">Initial value of the Remark property.</param>
 /// <param name="createTime">Initial value of the CreateTime property.</param>
 public static ItemsPackage CreateItemsPackage(global::System.Int32 id, global::System.String name, global::System.String remark, global::System.DateTime createTime)
 {
     ItemsPackage itemsPackage = new ItemsPackage();
     itemsPackage.Id = id;
     itemsPackage.Name = name;
     itemsPackage.Remark = remark;
     itemsPackage.CreateTime = createTime;
     return itemsPackage;
 }
Ejemplo n.º 4
0
        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");
        }