private static GenreBO FindGenreById() { WriteLine("Enter Q to go back to the menu"); GenreBO genre = null; while (genre == null) { int idSearch; string input = ReadLine(); if (int.TryParse(input, out idSearch)) { return(bllFacade.GenreService.GetGenreById(idSearch)); } else if (input.ToLower().Equals("q")) { break; } else { Write("You have to input the id"); } } return(null); }
private static GenreBO GenreExistCheck() { bool foundGenre = false; string str = ReadLine(); GenreBO genre = null; while (!foundGenre) { genre = bllFacade.GenreService.GetGenreByName(str); if (genre != null) { return(genre); } else { WriteLine("The genre inputted was not found"); WriteLine($"Do you wish to create a genre named {str}"); if (ExtraUI.ConfirmInfo()) { genre = new GenreBO { Name = str }; bllFacade.GenreService.CreateGenre(genre); return(genre); } else { } } str = ReadLine(); } return(null); }
internal Genre Convert(GenreBO Gen) { return(new Genre() { Id = Gen.Id, Name = Gen.Name }); }
public Genre Convert(GenreBO g) { return(new Genre { Id = g.Id, Name = g.Name }); }
public IActionResult Post([FromBody] GenreBO genre) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(facade.GenreService.Create(genre))); }
private Genre Convert(GenreBO vid) { return(new Genre() { Id = vid.Id, Name = vid.Name }); }
public GenreBO Add(GenreBO genre) { using (var uow = _facade.UnitOfWork) { var genreEntity = uow.GenreRepository.Add(conv.Convert(genre)); uow.Complete(); return(conv.Convert(genreEntity)); } }
public GenreBO Create(GenreBO gen) { using (var uow = facade.UnitOfWork) { var newGen = uow.GenreRepository.Create(Convert(gen)); uow.Complete(); return(Convert(newGen)); } }
public IActionResult Post([FromBody] GenreBO genre) { if (!ModelState.IsValid) { return(StatusCode(406, ModelState)); } return(Ok(_bllFacade.GenreService.Add(genre))); }
public GenreBO Create(GenreBO genre) { using (var uow = facade.UnitOfWork) { var newVideo = uow.GenreRepository.Create(converter.Convert(genre)); uow.Complete(); return(converter.Convert(newVideo)); } }
public GenreBO Create(GenreBO genre) { using (var uow = _facade.UnitOfWork) { var genreEntity = uow.GenreRepository.Create(gConverter.Convert(genre)); uow.Complete(); return(gConverter.Convert(genreEntity)); } }
public GenreBO Create(GenreBO genre) { using (var ouw = _facade.UnitOfWork) { var genreEntity = ouw.GenreRepository.Create(conv.Convert(genre)); ouw.Complete(); return(conv.Convert(genreEntity)); } }
public Genre Convert(GenreBO genre) { if (genre == null) { return(null); } return(new Genre { Id = genre.Id, Name = genre.Name }); }
internal Genre Convert(GenreBO genre) { if (genre == null) { return(null); } return(new Genre() { Id = genre.Id, Name = genre.Name }); }
internal Genre Convert(GenreBO genreBo) { if (genreBo == null) { return(null); } return(new Genre { Id = genreBo.Id, Name = genreBo.Name }); }
public void UpdateGenre(GenreBO g) { using (var uow = facade.UnitOfWork) { var vidFromDB = uow.GenreRepository.GetGenreById(g.Id); if (vidFromDB == null) { throw new InvalidOperationException("Genre Not Found"); } vidFromDB.Name = g.Name; uow.Complete(); } }
public GenreBO Create(GenreBO genre) { if (genre == null) { return(null); } using (var unitOfWork = _facade.UnitOfWork) { var createdGenre = unitOfWork.GenreRepository.Create(_converter.Convert(genre)); unitOfWork.Complete(); return(_converter.Convert(createdGenre)); } }
internal Genre Convert(GenreBO genreBO) { if (genreBO == null) { return(null); } return(new Genre() { Id = genreBO.Id, Name = genreBO.Name, //Video = new VideoConverter().Convert(genreBO.Video), VideoId = genreBO.VideoId }); }
public GenreBO Update(GenreBO genre) { using (var uow = facade.UnitOfWork) { var genreEntity = uow.GenreRepository.Get(genre.Id); if (genreEntity == null) { throw new InvalidOperationException("Genre not found"); } genreEntity.Name = genre.Name; uow.Complete(); return(conv.Convert(genreEntity)); } }
public GenreBO Update(GenreBO genre) { using (var uow = _facade.UnitOfWork) { var genreFromDb = uow.GenreRepository.GetById(genre.Id); if (genreFromDb == null) { throw new InvalidOperationException("Genre not found"); } genreFromDb.Name = genre.Name; uow.Complete(); return(gConverter.Convert(genreFromDb)); } }
internal Genre Convert(GenreBO genre) { if (genre != null) { return(new Genre() { Id = genre.Id, _Genre = genre.Genre }); } else { return(null); } }
public bool CreateGenre(GenreBO g) { bool success = false; using (var uow = facade.UnitOfWork) { if (uow.GenreRepository.GetAllGenres().FirstOrDefault(x => x.Name.ToLower().Equals(g.Name.ToLower())) == null) { uow.GenreRepository.CreateGenre(conv.Convert(g)); success = true; uow.Complete(); } return(success); } }
public IActionResult Put(int id, [FromBody] GenreBO genre) { if (id != genre.Id) { return(StatusCode(405, "Id's doesnt match")); } try { return(Ok(facade.GenreService.Update(genre))); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
internal Genre Convert(GenreBO genre) { if (genre == null) { return(null); } return(new Genre() { Id = genre.Id, GenreTitle = genre.GenreTitle, Videos = genre.VideoIds?.Select(id => new Video() { Id = id }).ToList() }); }
internal Genre Convert(GenreBO genre) { if (genre == null) { return(null); } return(new Genre() { Id = genre.Id, Horror = genre.Horror, Minecraft = genre.Minecraft, Romance = genre.Romance, Prank = genre.Prank, Video = new VideoConverter().Convert(genre.Video) }); }
public IActionResult Put(int id, [FromBody] GenreBO gen) { if (id != gen.Id) { return(BadRequest("Path id does not match Video Id in json")); } try { var video = facade.GenreService.Update(gen); return(Ok(video)); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public IActionResult Put(int id, [FromBody] GenreBO genre) { if (id != genre.Id) { return(BadRequest("Path Id does not match with Id from Json")); } try { var genreUpdated = facade.GenreService.Update(genre); return(Ok(genreUpdated)); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public GenreBO Update(GenreBO genre) { using (var ouw = _facade.UnitOfWork) { var genreEntity = ouw.GenreRepository.Get(genre.Id); if (genreEntity == null) { throw new InvalidOperationException("Genre not found"); } genreEntity.Horror = genre.Horror; genreEntity.Minecraft = genre.Minecraft; genreEntity.Romance = genre.Romance; genreEntity.Prank = genre.Prank; ouw.Complete(); return(conv.Convert(genreEntity)); } }
public GenreBO Update(GenreBO entityToUpdate) { using (var unitOfWork = _facade.UnitOfWork) { var genreFromRepo = unitOfWork.GenreRepository.GetById(entityToUpdate.Id); if (genreFromRepo == null) { return(null); } genreFromRepo.Name = entityToUpdate.Name; var updatedVideo = unitOfWork.GenreRepository.Update(genreFromRepo); unitOfWork.Complete(); return(_converter.Convert(updatedVideo)); } }
public GenreBO Update(GenreBO genre) { using (var uow = _facade.UnitOfWork) { var GenreEntity = uow.GenreRepository.Get(genre.Id); if (GenreEntity != null) { uow.GenreRepository.Get(GenreEntity.Id)._Genre = genre.Genre; uow.Complete(); return(conv.Convert(GenreEntity)); } else { throw new InvalidOperationException("Genre not found."); } } }