/// <summary>
 /// Deprecated Method for adding a new object to the Natures EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNatures(Natures natures)
 {
     base.AddObject("Natures", natures);
 }
Exemplo n.º 2
0
        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");
        }
 /// <summary>
 /// Create a new Natures object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="time">Initial value of the Time property.</param>
 public static Natures CreateNatures(global::System.Int32 id, global::System.DateTime date, global::System.Int32 time)
 {
     Natures natures = new Natures();
     natures.Id = id;
     natures.Date = date;
     natures.Time = time;
     return natures;
 }
Exemplo n.º 4
0
 public ActionResult AddNatures(Natures na)
 {
     na.Status = "等待";
     na.Feedback = "";
     DBContext.AddToNatures(na);
     DBContext.SaveChanges();
     return RedirectToAction("Calendar");
 }