public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var post = await _context.Posts.FindAsync(request.id); _context.Remove(post); await _context.SaveChangesAsync(); return(Unit.Value); }
public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var activity = await _datacontext.Activities.FindAsync(request.ActivityId); if (activity == null) { throw new RestException(HttpStatusCode.NotFound, new { activity = "Not Found" }); } _datacontext.Remove(activity); // Handler Logic var success = await _datacontext.SaveChangesAsync() > 0; if (success) { return(Unit.Value); } throw new Exception("Problem Delete Activity"); }