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 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)); } }
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 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)); } }
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)); } }
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)); } }
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 async Task <GenreDto> CreateAsync(GenreDto item) { var result = _context.Genres.Add(GenreConverter.Convert(item)); await _context.SaveChangesAsync(); return(GenreConverter.Convert(result.Entity)); }
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); }
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); } }
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); } }
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); } }
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); } }
public async Task <GenreDto> GetByIdAsync(Guid id) { var genre = GenreConverter.Convert(await _context.Genres.FindAsync(id)); return(genre); }
public async Task <List <GenreDto> > GetAllAsync() { return(GenreConverter.Convert(await _context.Genres.ToListAsync())); }
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); } }
public async Task <GenreDto> GetById(Guid id) { return(GenreConverter.Convert(await _context.Genres.FindAsync(id))); }