public async Task HandleAsync(UpdatePackageCommand command) { bool done = false; IPackage model; while (!done) { try { model = await repo.Get(command.Updates.Id); if (model == null) { return; } model.FullUpdate(command.Updates); await mediator.TriggerEvents(model.DomainEvents); await repo.UnitOfWork.SaveEntitiesAsync(); done = true; } catch (DbUpdateConcurrencyException) { //add here some logging } } }
public async Task HandleAsync(DeletePackageCommand command) { var deleted = await repo.Delete(command.PackageId); if (deleted != null) { await mediator.TriggerEvents(deleted.DomainEvents); } await repo.UnitOfWork.SaveEntitiesAsync(); }