Exemple #1
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Models.StoryCollection StoryCollection = new Models.StoryCollection();
                Models.Collage         collage         = new Models.Collage();

                string    path = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml");
                XDocument doc  = XDocument.Load(path);
                if (!doc.Element("collages").Elements("collage").Any())
                {
                    collage.id = 1;
                }
                else
                {
                    collage.id = (int)(from S in doc.Descendants("collage")
                                       orderby(int) S.Element("id")
                                       descending
                                       select(int) S.Element("id")).FirstOrDefault() + 1;
                }
                collage.collageName = collection["CollageName"];
                string checkResp = collection["checkResp"];
                collage.storyId = checkResp.Split(',').ToList();

                StoryCollection.CollectionList.Add(collage);
                StoryCollection.Create(collage);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Models.StoryCollection StoryCollection = new Models.StoryCollection();
                Models.Collage collage = new Models.Collage();

                string path = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml");
                XDocument doc = XDocument.Load(path);
                if(!doc.Element("collages").Elements("collage").Any())
                {
                    collage.id = 1;
                }
                else {
                    collage.id = (int)(from S in doc.Descendants("collage")
                                   orderby (int)S.Element("id")
                                   descending
                                   select (int)S.Element("id")).FirstOrDefault()+1;
                }
                collage.collageName = collection["CollageName"];
                string checkResp = collection["checkResp"];
                collage.storyId = checkResp.Split(',').ToList();

                StoryCollection.CollectionList.Add(collage);
                StoryCollection.Create(collage);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }