public virtual async Task <IStatusResponse> DeleteAsync( DeletePersonRequest model, CancellationToken token = default) { model.ArgumentNullCheck(nameof(model)); var entity = await store.GetEntityAsync(model.Id, token); IStatusResponse response; if (entity == null) { response = NotFoundStatusResponse(model.Id); } else { context.Set <Person>().Remove(entity); context.Set <Address>().Remove(entity.Address); context.Set <Name>().Remove(entity.Name); await context.SaveChangesAsync(token); await eventDispatcher.DispatchAsync(new Events.DeleteEvent(entity)); response = new StatusResponse(model.Id); } return(response); }
public virtual async Task <IStatusResponse> DeleteAsync( DeletePersonRequest model, CancellationToken token = default) { model.ArgumentNullCheck(nameof(model)); using (var scope = TransactionFactory.CreateTransaction()) { var result = await service.DeleteAsync(model, token); scope.Complete(); return(result); } }