Ejemplo n.º 1
0
        public async Task <bool> TryUploadAsync(Photo photoForUploading, List <int> genresId)
        {
            bool success = true;

            var photoEntityExist = await _context.Photos
                                   .AnyAsync(photoEntity => photoEntity.Name == photoForUploading.Name);

            if (photoEntityExist == true)
            {
                success = false;
            }
            else
            {
                var entityPhoto = _mapper.Map <PhotoEntity>(photoForUploading);
                var photo       = _context.Photos.Add(entityPhoto).Entity;
                await _context.SaveChangesAsync();

                photo.Genres = _context.Genres
                               .Where(genre => genresId
                                      .Contains(genre.Id))
                               .ToList();

                _context.Update(photo);
                await _context.SaveChangesAsync();

                success = true;
            }

            return(success);
        }
Ejemplo n.º 2
0
 public async Task UpdateAsync(User model)
 {
     db.Update(model);
 }
Ejemplo n.º 3
0
 public async Task UpdateAsync(Photo model)
 {
     db.Update(model);
 }