public HomeController(IDaoFilm filmsDao, IDaoGenre genresDao, IDaoActor actorsDao) { FilmsDao = filmsDao; GenresDao = genresDao; ActorsDao = actorsDao; //FilmsDbEmulXml.Films = FilmsDao.FindAll(); //FilmsDbEmulXml.Serialize(); }
public ActorsController(IDaoActor actorsDao, IDaoFilm filmsDao, IDaoCountry countriesDao) { Validator.RequireNotNull(actorsDao); Validator.RequireNotNull(filmsDao); Validator.RequireNotNull(countriesDao); ActorsDao = actorsDao; FilmsDao = filmsDao; CountriesDao = countriesDao; }
public override List <Entidad> Ejecutar(string parametro) { try { FabricaDAOSqlServer laFabrica = new FabricaDAOSqlServer(); IDaoActor daoActor = laFabrica.ObtenerDAOActor(); return(daoActor.ConsultarListarActores(parametro)); } catch (BDDAOException ex) { ComandoBDException exComandoAgregarActor = new ComandoBDException( RecursosComandosModulo6.CodigoExcepcionComandoBD, RecursosComandosModulo6.MensajeExcepcionComandoBD, ex); Logger.EscribirError(RecursosComandosModulo6.ClaseComandoAgregarActor, exComandoAgregarActor); throw exComandoAgregarActor; } catch (ObjetoNuloDAOException ex) { ComandoNullException exComandoAgregarActor = new ComandoNullException( RecursosComandosModulo6.CodigoExcepcionComandoObjetoNulo, RecursosComandosModulo6.MensajeExcepcionComandoObjetoNulo, ex); Logger.EscribirError(RecursosComandosModulo6.ClaseComandoAgregarActor, exComandoAgregarActor); throw exComandoAgregarActor; } catch (ErrorDesconocidoDAOException ex) { ComandoException exComandoAgregarActor = new ComandoException( RecursosComandosModulo6.CodigoExcepcionComandoError, RecursosComandosModulo6.MensajeExcepcionComandoError, ex); Logger.EscribirError(RecursosComandosModulo6.ClaseComandoAgregarActor, exComandoAgregarActor); throw exComandoAgregarActor; } }
public override List <Entidad> Ejecutar(Entidad parametro) { try { FabricaAbstractaDAO laFabrica = FabricaAbstractaDAO.ObtenerFabricaSqlServer(); IDaoActor daoActor = laFabrica.ObtenerDAOActor(); return(daoActor.consultarListaDeActores(parametro)); } catch (ConsultarTodosActoresBDDAOException ex) { ConsultarTodosActoresBDDAOException exComandoConsultarActores = new ConsultarTodosActoresBDDAOException( RecursosComandosModulo6.CodigoExcepcionComandoConsultarActoresBD, RecursosComandosModulo6.MensajeExcepcionComandoConsultarActoresBD, ex); Logger.EscribirError(RecursosComandosModulo6.ClaseComandoConsultarActores, exComandoConsultarActores); throw exComandoConsultarActores; } catch (ConsultarTodosActoresNuloDAOException ex) { ConsultarActoresComandoNullException exComandoConsultarActores = new ConsultarActoresComandoNullException( RecursosComandosModulo6.CodigoExcepcionComandoConsultarActoresNulo, RecursosComandosModulo6.MensajeExcepcionComandoConsultarActoresNulo, ex); Logger.EscribirError(RecursosComandosModulo6.ClaseComandoConsultarActores, exComandoConsultarActores); throw exComandoConsultarActores; } catch (ConsultarTodosActoresDAOException ex) { ConsultarActoresComandoException exComandoConsultarActores = new ConsultarActoresComandoException( RecursosComandosModulo6.MensajeExcepcionComandoConsultarActoresError, RecursosComandosModulo6.MensajeExcepcionComandoConsultarActoresError, ex); Logger.EscribirError(RecursosComandosModulo6.ClaseComandoConsultarActores, exComandoConsultarActores); throw exComandoConsultarActores; } }
public FilmsController(IDaoFilm filmsDao, IDaoActor actorsDao, IDaoDirector directorsDao, IDaoGenre genresDao, IDaoCountry countriesDao) { Validator.RequireNotNull(filmsDao); Validator.RequireNotNull(actorsDao); Validator.RequireNotNull(directorsDao); Validator.RequireNotNull(genresDao); Validator.RequireNotNull(countriesDao); FilmsDao = filmsDao; ActorsDao = actorsDao; DirectorsDao = directorsDao; GenresDao = genresDao; CountriesDao = countriesDao; //var emul = FilmsDbEmulXml.Deserialize(); }
public static void CopyToData(this FilmInput input, Film data, HttpPostedFileBase poster, IDaoCountry daoCountry, IDaoGenre daoGenre, IDaoDirector daoDirector, IDaoActor daoActor) { if (data.ID != input.ID) { throw new Exception("Cannot copy from foreign view to data"); } data.Title = input.Title; data.ReleaseDate = input.ReleaseDate; data.IMDbRating = input.IMDbRating; data.Duration = input.Duration; data.Description = input.Description; data.Countries = new List <Country>(); foreach (var name in input.Countries) { data.Countries.Add(daoCountry.GetCountryByEnglishName(name)); } data.RemoveAllGenres(); if (input.Genres != null) { foreach (var id in input.Genres) { var genre = daoGenre.Find(id); data.AddGenre(genre); } } if (input.DirectorID != Guid.Empty) { data.Director = daoDirector.Find(input.DirectorID); } data.RemoveAllActors(); if (input.Actors != null) { foreach (var id in input.Actors) { var actor = daoActor.Find(id); data.AddActor(actor); } } if (poster != null && poster.ContentLength > 0) { try { if (poster.ContentType.Contains("image")) { var filename = Guid.NewGuid().ToString() + Path.GetExtension(poster.FileName); var path = Path.Combine(PathUtils.GetProjectDirectory(), "Cinematheque.WebSite\\images\\films\\", filename); poster.SaveAs(path); /*File.Delete(Path.Combine(PathUtils.GetProjectDirectory(), * "Cinematheque.WebSite\\images\\films\\", * filename);*/ data.PosterFileName = filename; } else { throw new Exception("ERROR: Uploaded file is not image"); } } catch (Exception ex) { throw new Exception("ERROR:" + ex.Message.ToString()); } } }
public static Film CreateFilm(this FilmInput input, HttpPostedFileBase poster, IDaoCountry daoCountry, IDaoActor daoActor, IDaoDirector daoDirector, IDaoGenre daoGenre) { var film = new Film { Title = input.Title, ReleaseDate = input.ReleaseDate, IMDbRating = input.IMDbRating, Duration = input.Duration, Description = input.Description, Countries = new List <Country>() }; foreach (var name in input.Countries) { film.Countries.Add(daoCountry.GetCountryByEnglishName(name)); } if (poster != null && poster.ContentLength > 0) { try { if (poster.ContentType.Contains("image")) { var filename = Guid.NewGuid().ToString() + Path.GetExtension(poster.FileName); var path = Path.Combine(PathUtils.GetProjectDirectory(), "Cinematheque.WebSite\\images\\films\\", filename); poster.SaveAs(path); film.PosterFileName = filename; } else { throw new Exception("ERROR: Uploaded file is not image"); } } catch (Exception ex) { throw new Exception("ERROR:" + ex.Message.ToString()); } } else { film.PosterFileName = "default.jpg"; } if (input.Genres != null) { foreach (var id in input.Genres) { var genre = daoGenre.Find(id); film.AddGenre(genre); } } film.Director = daoDirector.Find(input.DirectorID); if (input.Actors != null) { foreach (var id in input.Actors) { var actor = daoActor.Find(id); film.AddActor(actor); } } return(film); }