public void AddGenre(GenreDM genreDM) { UOW.Genres.Create(new Genre { Name = genreDM.Name }); UOW.Save(); }
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 })); } }
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"); } }
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"); } }
public GenreView(GenreDM genre) { GenreID = genre.GenreID; Name = genre.Name; }