//----< GET api/File - get list of available files >---------------
        public IEnumerable<string> Get(string level)
        {
            // available files
            if(level == "collage"){
                Models.StoryCollection clg = new Models.StoryCollection();

                string[] files = new string[clg.CollectionList.Count()];
                int i = 0;
                foreach (var colg in clg.CollectionList) {
                      string id = colg.id.ToString();
                      string name = colg.collageName;
                      files[i] = name+"_"+id ;
                      i++;
                }
                return files;
            }
            else
            {
                Models.Collage collage = new Models.Collage();
                string[] files = new string[collage.storyList.Count()];
                int i = 0;
                foreach (var story in collage.storyList)
                {
                    string id = story.id.ToString();
                    string name = story.storyCaption;
                    files[i] = name + "_" + id;
                    i++;
                }
                return files;
            }
        }
        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();
            }
        }
        //----< GET api/File - get list of available files >---------------

        public IEnumerable <string> Get(string level)
        {
            // available files
            if (level == "collage")
            {
                Models.StoryCollection clg = new Models.StoryCollection();

                string[] files = new string[clg.CollectionList.Count()];
                int      i     = 0;
                foreach (var colg in clg.CollectionList)
                {
                    string id   = colg.id.ToString();
                    string name = colg.collageName;
                    files[i] = name + "_" + id;
                    i++;
                }
                return(files);
            }
            else
            {
                Models.Collage collage = new Models.Collage();
                string[]       files   = new string[collage.storyList.Count()];
                int            i       = 0;
                foreach (var story in collage.storyList)
                {
                    string id   = story.id.ToString();
                    string name = story.storyCaption;
                    files[i] = name + "_" + id;
                    i++;
                }
                return(files);
            }
        }
Exemple #4
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());
            }
        }
Exemple #5
0
 public ActionResult Edit(int id)
 {
     try
     {
         Models.StoryCollection StoryCollection = new Models.StoryCollection();
         foreach (Models.Collage collage in StoryCollection.CollectionList)
         {
             if (collage.id == id)
             {
                 return(View(collage));
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Delete(int id)
 {
     try
     {
         Models.StoryCollection StoryCollection = new Models.StoryCollection();
         foreach (Models.Collage collage in StoryCollection.CollectionList)
         {
             if (collage.id == id)
             {
                 return View(collage);
             }
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return RedirectToAction("Index");
     }
 }
Exemple #7
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         Models.StoryCollection StoryCollection = new Models.StoryCollection();
         foreach (Models.Collage collage in StoryCollection.CollectionList)
         {
             if (collage.id == id)
             {
                 StoryCollection.CollectionList.Remove(collage);
                 StoryCollection.Delete(collage);
                 break;
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #8
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         Models.StoryCollection StoryCollection = new Models.StoryCollection();
         foreach (Models.Collage collage in StoryCollection.CollectionList)
         {
             if (collage.id == id)
             {
                 collage.collageName = collection["CollageName"];
                 string checkResp = collection["checkResp"];
                 collage.storyId = checkResp.Split(',').ToList();
                 StoryCollection.Edit(collage);
                 break;
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #9
0
 public ActionResult Index(Models.StoryCollection clg)
 {
     return(View(clg.CollectionList));
 }
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         Models.StoryCollection StoryCollection = new Models.StoryCollection();
         foreach (Models.Collage collage in StoryCollection.CollectionList)
         {
             if (collage.id == id)
             {
                 collage.collageName = collection["CollageName"];
                 string checkResp = collection["checkResp"];
                 collage.storyId = checkResp.Split(',').ToList();
                 StoryCollection.Edit(collage);
                 break;
             }
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }