示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 internal Genre Convert(GenreBO Gen)
 {
     return(new Genre()
     {
         Id = Gen.Id,
         Name = Gen.Name
     });
 }
示例#4
0
 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
     });
 }
示例#7
0
 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));
     }
 }
示例#9
0
        public IActionResult Post([FromBody] GenreBO genre)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(406, ModelState));
            }

            return(Ok(_bllFacade.GenreService.Add(genre)));
        }
示例#10
0
 public GenreBO Create(GenreBO genre)
 {
     using (var uow = facade.UnitOfWork)
     {
         var newVideo = uow.GenreRepository.Create(converter.Convert(genre));
         uow.Complete();
         return(converter.Convert(newVideo));
     }
 }
示例#11
0
 public GenreBO Create(GenreBO genre)
 {
     using (var uow = _facade.UnitOfWork)
     {
         var genreEntity = uow.GenreRepository.Create(gConverter.Convert(genre));
         uow.Complete();
         return(gConverter.Convert(genreEntity));
     }
 }
示例#12
0
 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
     });
 }
示例#14
0
 internal Genre Convert(GenreBO genre)
 {
     if (genre == null)
     {
         return(null);
     }
     return(new Genre()
     {
         Id = genre.Id,
         Name = genre.Name
     });
 }
示例#15
0
        internal Genre Convert(GenreBO genreBo)
        {
            if (genreBo == null)
            {
                return(null);
            }

            return(new Genre
            {
                Id = genreBo.Id,
                Name = genreBo.Name
            });
        }
示例#16
0
 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();
     }
 }
示例#17
0
 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));
     }
 }
示例#18
0
 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
     });
 }
示例#19
0
 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));
     }
 }
示例#20
0
 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));
     }
 }
示例#21
0
 internal Genre Convert(GenreBO genre)
 {
     if (genre != null)
     {
         return(new Genre()
         {
             Id = genre.Id,
             _Genre = genre.Genre
         });
     }
     else
     {
         return(null);
     }
 }
示例#22
0
        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));
     }
 }
示例#24
0
 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()
     });
 }
示例#25
0
 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)
     });
 }
示例#26
0
 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));
     }
 }
示例#28
0
 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));
     }
 }
示例#29
0
        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));
            }
        }
示例#30
0
 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.");
         }
     }
 }