/// <summary>
 /// Create a new NaturesItems object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="itemId">Initial value of the ItemId property.</param>
 /// <param name="listId">Initial value of the ListId property.</param>
 /// <param name="naId">Initial value of the NaId property.</param>
 public static NaturesItems CreateNaturesItems(global::System.Int32 id, global::System.Int32 itemId, global::System.Int32 listId, global::System.Int32 naId)
 {
     NaturesItems naturesItems = new NaturesItems();
     naturesItems.Id = id;
     naturesItems.ItemId = itemId;
     naturesItems.ListId = listId;
     naturesItems.NaId = naId;
     return naturesItems;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the NaturesItemsSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNaturesItemsSet(NaturesItems naturesItems)
 {
     base.AddObject("NaturesItemsSet", naturesItems);
 }
        public ActionResult DetailNatures(Natures na)
        {
            var obj = DBContext.Natures.FirstOrDefault(e => e.Id == na.Id);
            obj.Feedback = na.Feedback == null ? "" : na.Feedback;
            if (obj.Feedback != "")
                obj.Status = "已参观";
            var list = DBContext.NaturesItemsSet.Where(e => e.NaId == na.Id);
            foreach (var v in list)
            {
                DBContext.DeleteObject(v);
            }
            if (Request.Form["resourceid"] != null && Request.Form["playname"] != null)
            {
                string[] items = Request.Form["resourceid"].Split(',');
                string[] playnames = Request.Form["playname"].Split(',');

                for (int i = 0; i < items.Length; i++)
                {
                    if (items[i] != string.Empty && playnames[i] != string.Empty)
                    {
                        NaturesItems ir = new NaturesItems { ListId = int.Parse(items[i]), ItemId = int.Parse(playnames[i]), NaId = na.Id };
                        DBContext.AddToNaturesItemsSet(ir);
                    }
                }
            }
            DBContext.SaveChanges();
            var follow = DBContext.NaturesItemsSet.Where(e => e.NaId == na.Id).ToList();
            foreach (var v in follow)
            {
                v.FollowLevel = "";
            }
            if (Request.Form["follow"] != null && Request.Form["level"] != null)
            {
                string[] listids = Request.Form["resourceid"].Split(',');
                string[] levels = Request.Form["level"].Split(',');
                for (int i = 0; i < listids.Length; i++)
                {
                    int id = int.Parse(listids[i]);
                    var result = follow.Where(e => e.ListId == id && e.NaId == na.Id);
                    foreach (var r in result)
                    {
                        r.FollowLevel = levels[i];
                    }
                }
            }
            DBContext.SaveChanges();
            return RedirectToAction("Calendar");
        }