public Task <Unit> Handle(DeleteCopy request, CancellationToken cancellationToken) { var copy = _context.Copies.Single(c => c.Id == request.CopyId); _context.Remove(copy); _context.SaveChanges(); return(Unit.Task); }
public async Task <Unit> Handle(DeleteImage request, CancellationToken cancellationToken) { var image = _context.PlatformGameImages.Single(pgi => pgi.Id == request.Id); _context.PlatformGameImages.Remove(image); _context.SaveChanges(); await _mediator.Send(new RemoveImageFromStorage { GameId = image.GameId, ImageId = request.Id }, cancellationToken); return(Unit.Value); }
public Task <Unit> Handle(ToggleImageAsCoverArt request, CancellationToken cancellationToken) { var image = _context.PlatformGameImages.Single(pgi => pgi.Id == request.ImageId); var currentCoverArtImage = _context.PlatformGameImages.SingleOrDefault(pgi => pgi.Id != request.ImageId && pgi.GameId == image.GameId && pgi.IsCoverArt); image.IsCoverArt = !image.IsCoverArt; if (currentCoverArtImage != null) { currentCoverArtImage.IsCoverArt = false; } _context.SaveChanges(); return(Unit.Task); }
public Task <Guid> Handle(RegisterGenre request, CancellationToken cancellationToken) { var existing = _context.Genres.SingleOrDefault(g => g.Name == request.Name); if (existing == null) { var genre = new Genre { Name = request.Name }; _context.Genres.Add(genre); _context.SaveChanges(); return(Task.FromResult(genre.Id)); } return(Task.FromResult(existing.Id)); }
public bool Verify(string email) { if (!string.IsNullOrEmpty(email)) { var user = _context.Users.SingleOrDefault(u => u.Email == email); if (user == null) { user = new User { Email = email, TenantId = Guid.NewGuid() }; _context.Add(user); _context.SaveChanges(); } return(true); } return(false); }