public async Task <Unit> Handle(DeleteDestinationCommand request, CancellationToken cancellationToken) { var entity = await _context.Destinations.FindAsync(request.Id); if (entity == null) { //throw NotFound } _context.Destinations.Remove(entity); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public async Task <int> Handle(CreateDestinationCommand request, CancellationToken cancellationToken) { var entity = new Destination { Note = request.Note, Longitude = request.Longitude, Latitude = request.Latitude, }; _context.Destinations.Add(entity); await _context.SaveChangesAsync(cancellationToken); return(entity.Id); }