Beispiel #1
0
        public void AddGenre(GenreDM genreDM)
        {
            UOW.Genres.Create(new Genre
            {
                Name = genreDM.Name
            });

            UOW.Save();
        }
Beispiel #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            GenreDM genreDM = service.GetGenre(Convert.ToInt32(id));
            bool    flag    = service.DeleteGenre(genreDM);

            if (flag)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Error", new { id = id }));
            }
        }
Beispiel #3
0
        public void UpdateGenre(GenreDM genreDM)
        {
            try
            {
                UOW.Genres.Update(new Genre
                {
                    GenreID = genreDM.GenreID,
                    Name    = genreDM.Name
                });

                UOW.Save();
            }
            catch (Exception ex)
            {
                throw new DataException(ex.Message, "Error in updating Genre");
            }
        }
Beispiel #4
0
        public bool DeleteGenre(GenreDM genreDM)
        {
            try
            {
                Genre genre = UOW.Genres.Get(genreDM.GenreID);

                if (UOW.Books.Find(b => b.GenreID
                                   == genre.GenreID).Count() == 0)
                {
                    UOW.Genres.Delete(genre.GenreID);
                    UOW.Save();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw new DataException(ex.Message, "Error in deleting Genre");
            }
        }
Beispiel #5
0
 public GenreView(GenreDM genre)
 {
     GenreID = genre.GenreID;
     Name    = genre.Name;
 }