Example #1
0
        public ActionResult AddTitle(TitleViewModel titleViewModel)
        {
            using (var comicbookContext = new ComicBookContext())
            {
                var title = new Title
                {
                    //TitleId = nextTitleId,  Don't need.
                    Name   = titleViewModel.Name,
                    Artist = titleViewModel.Artist
                };

                comicbookContext.Titles.Add(title);
                comicbookContext.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult DeleteTitle(TitleViewModel titleViewModel)
        {
            using (var comicbookContext = new ComicBookContext())
            {
                var title = comicbookContext.Titles.SingleOrDefault(p => p.TitleId == titleViewModel.TitleId);

                if (title != null)
                {
                    comicbookContext.Titles.Remove(title);
                    comicbookContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(new HttpNotFoundResult());
        }
Example #3
0
        public ActionResult EditTitle(TitleViewModel titleViewModel)
        {
            using (var comicbookContext = new ComicBookContext())
            {
                var title = comicbookContext.Titles.SingleOrDefault(p => p.TitleId == titleViewModel.TitleId);

                if (title != null)
                {
                    title.Name   = titleViewModel.Name;
                    title.Artist = titleViewModel.Artist;
                    comicbookContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(new HttpNotFoundResult());
        }
 public virtual void SaveChanges()
 {
     _comicBookContext.SaveChanges();
 }