예제 #1
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AdventureTime_Story story = storyRepo.Stories.FirstOrDefault(s => s.StoryID == id);

            if (story.StoryID != id)
            {
                return(HttpNotFound());
            }
            return(View(story));
        }
예제 #2
0
        public void DeleteStory(AdventureTime_Story story)
        {
            foreach (var paragragh in context.Paragraphs)
            {
                if (story.StoryID == paragragh.StoryID)
                {
                    context.Paragraphs.Remove(paragragh);
                    context.SaveChanges();
                }
            }

            context.Stories.Remove(story);
            context.SaveChanges();
        }
예제 #3
0
 public ActionResult Edit(AdventureTime_Story story)
 {
     try
     {
         if (ModelState.IsValid)
         {
             storyRepo.SaveStory(story);
             return(RedirectToAction("List"));
         }
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Story", "Edit")));
     }
     return(View(story));
 }
예제 #4
0
        // Save new stories or make changes to existing stories
        public void SaveStory(AdventureTime_Story story)
        {
            // Check to see if story exists
            if (story.StoryID == 0)
            {
                context.Stories.Add(story);
            }
            else
            {
                // Retrieve existing story and rewrite any changes
                AdventureTime_Story dbEntry = context.Stories.Find(story.StoryID);
                if (dbEntry != null)
                {
                    dbEntry.StoryID     = story.StoryID;
                    dbEntry.StoryTitle  = story.StoryTitle;
                    dbEntry.StoryGenre  = story.StoryGenre;
                    dbEntry.AuthorID    = story.AuthorID;
                    dbEntry.DateCreated = story.DateCreated;
                }
            }

            context.SaveChanges();
        }
예제 #5
0
        public ViewResult Edit(int id)
        {
            AdventureTime_Story story = storyRepo.Stories.FirstOrDefault(s => s.StoryID == id);

            return(View(story));
        }
예제 #6
0
 public ActionResult Delete(AdventureTime_Story story)
 {
     storyRepo.DeleteStory(story);
     return(View("List"));
 }