示例#1
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));
     }
 }
示例#2
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 GenreBO Create(GenreBO genre)
 {
     using (var uow = _facade.UnitOfWork)
     {
         var genreEntity = uow.GenreRepository.Create(gConverter.Convert(genre));
         uow.Complete();
         return(gConverter.Convert(genreEntity));
     }
 }
示例#4
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));
     }
 }
示例#5
0
 public BOGenre Create(BOGenre genre)
 {
     // using - invoke the dipose function. Make sure that we aren't connected to anything and database is closed.
     using (var uow = facade.UnitOfWork)
     {
         var genreEntity = uow.GenreRepository.Create(conv.Convert(genre));
         uow.Complete();
         return(conv.Convert(genreEntity));
     }
 }
示例#6
0
 public GenreBO Add(GenreBO genre)
 {
     using (var unitOfWork = _dalFacade.UnitOfWork)
     {
         var newGenre = unitOfWork.GenreRepository.Add(_genreConverter.Convert(genre));
         unitOfWork.Complete();
         unitOfWork.Dispose();
         return(_genreConverter.Convert(newGenre));
     }
 }
示例#7
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));
     }
 }
示例#8
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);
            }
        }
示例#9
0
        public async Task <GenreDto> CreateAsync(GenreDto item)
        {
            var result = _context.Genres.Add(GenreConverter.Convert(item));
            await _context.SaveChangesAsync();

            return(GenreConverter.Convert(result.Entity));
        }
示例#10
0
        public async Task <GenreViewModel> GetGenreByIdAsync(int id, CancellationToken ct = default(CancellationToken))
        {
            var genreViewModel = GenreConverter.Convert(await _genreRepository.GetByIdAsync(id, ct));

            genreViewModel.Tracks = await GetTrackByGenreIdAsync(genreViewModel.GenreId, ct);

            return(genreViewModel);
        }
示例#11
0
        public async Task <bool> UpdateAsync(GenreDto item)
        {
            if (item == null)
            {
                return(false);
            }
            _context.Genres.Update(GenreConverter.Convert(item));
            await _context.SaveChangesAsync();

            return(true);
        }
 /// <summary>
 /// Gets the video that have the parsed id.
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public VideoBO GetOne(int id)
 {
     using (var uow = _facade.UnitOfWork)
     {
         var video = _converter.Convert(uow.VideoRepository.Get(id));
         video.Genre   = _genreConverter.Convert(uow.GenreRepository.Get(video.GenreId));
         video.Rentals = uow.RentalRepository.SearchByVideoId(video.Id).Select(_rentalConverter.Convert).ToList();
         video.Rentals.ForEach(v => v.User = _userConverter.Convert(uow.UserRepository.Get(v.UserId)));
         return(video);
     }
 }
示例#13
0
 public VideoBO Get(int Id)
 {
     using (var uow = facade.UnitOfWork)
     {
         var videoEntity = uow.VideoRepository.Get(Id);
         var genreEntity = uow.GenreRepository.Get(videoEntity.GenreId);
         var videoBO     = conv.Convert(videoEntity);
         if (genreEntity != null)
         {
             videoBO.Genre = gConv.Convert(genreEntity);
         }
         return(videoBO);
     }
 }
示例#14
0
 public VideoBO GetById(int id)
 {
     using (var unitOfWork = _facade.UnitOfWork)
     {
         var videoFromDB = unitOfWork.VideoRepository.GetById(id);
         if (videoFromDB == null)
         {
             return(null);
         }
         var convertedVideo = _converter.Convert(videoFromDB);
         // Get all genres for video
         convertedVideo.Genres = unitOfWork.GenreRepository.GetAllByIds(convertedVideo.GenreIds)?
                                 .Select(g => _genreConverter.Convert(g))
                                 .ToList();
         return(convertedVideo);
     }
 }
示例#15
0
        public List <GenreBO> AddGenre(List <GenreBO> gens)
        {
            using (var uow = _facade.UnitOfWork)
            {
                foreach (var gen in gens)
                {
                    var newGen = uow.GenreRepository.Create(conv.Convert(gen));
                }

                uow.Complete();

                return(gens);
            }
        }
示例#16
0
        public async Task <GenreDto> GetByIdAsync(Guid id)
        {
            var genre = GenreConverter.Convert(await _context.Genres.FindAsync(id));

            return(genre);
        }
示例#17
0
 public async Task <List <GenreDto> > GetAllAsync()
 {
     return(GenreConverter.Convert(await _context.Genres.ToListAsync()));
 }
示例#18
0
        public VideoBO Get(int Id)
        {
            using (var uow = facade.UnitOfWork)
            {
                var vid = conv.Convert(uow.VideoRepository.Get(Id));

                //vid.Genres = vid.GenreIDs?.Select(id => gConv.Convert(uow.GenreRepository.Get(id))).ToList();

                vid.Genres = uow.GenreRepository.GetAllById(vid.GenreIDs).Select(g => gConv.Convert(g)).ToList();

                return(vid);
            }
        }
示例#19
0
 public async Task <GenreDto> GetById(Guid id)
 {
     return(GenreConverter.Convert(await _context.Genres.FindAsync(id)));
 }