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); }
public async Task UpdateAsync(User model) { db.Update(model); }
public async Task UpdateAsync(Photo model) { db.Update(model); }