コード例 #1
0
 public ActionResult AddItems(Items item)
 {
     item.CreateTime = DateTime.Now;
     DBContext.AddToItems(item);
     DBContext.SaveChanges();
     if (Request.Form["resourceid"] != null && Request.Form["diveceid"] != null)
     {
         string[] resources = Request.Form["resourceid"].TrimEnd(',').Split(',');
         string[] devices = Request.Form["diveceid"].TrimEnd(',').Split(',');
         string str = Request.Form["PlayName"];
         for (int i = 0; i < resources.Length; i++)
         {
             if (resources[i] != string.Empty && devices[i] != string.Empty)
             {
                 ItemsResources ir = new ItemsResources { ItemId = item.Id, ResourceId = int.Parse(resources[i]), DeviceId = int.Parse(devices[i])};
                 DBContext.AddToItemsResources(ir);
             }
         }
         DBContext.SaveChanges();
     }
     return RedirectToAction("IndexItems");
 }
コード例 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Items EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToItems(Items items)
 {
     base.AddObject("Items", items);
 }
コード例 #3
0
 /// <summary>
 /// Create a new Items 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>
 /// <param name="listId">Initial value of the ListId property.</param>
 public static Items CreateItems(global::System.Int32 id, global::System.String name, global::System.String remark, global::System.DateTime createTime, global::System.Int32 listId)
 {
     Items items = new Items();
     items.Id = id;
     items.Name = name;
     items.Remark = remark;
     items.CreateTime = createTime;
     items.ListId = listId;
     return items;
 }
コード例 #4
0
 public ActionResult EditItems(Items item)
 {
     var items = DBContext.Items.Where(e => e.Id == item.Id).FirstOrDefault();
     items.Name = item.Name;
     items.Remark = item.Remark;
     var delObj = DBContext.ItemsResources.Where(e => e.ItemId == items.Id);
     foreach (var v in delObj)
         DBContext.DeleteObject(v);
     if (Request.Form["resourceid"] != null && Request.Form["diveceid"] != null)
     {
         string[] resources = Request.Form["resourceid"].TrimEnd(',').Split(',');
         string[] devices = Request.Form["diveceid"].TrimEnd(',').Split(',');
         string str = Request.Form["PlayName"];
         for (int i = 0; i < resources.Length; i++)
         {
             if (resources[i] != string.Empty && devices[i] != string.Empty)
             {
                 ItemsResources ir = new ItemsResources { ItemId = item.Id, ResourceId = int.Parse(resources[i]), DeviceId = int.Parse(devices[i]) };
                 DBContext.AddToItemsResources(ir);
             }
         }
     }
     DBContext.SaveChanges();
     return RedirectToAction("IndexItems");
 }