public virtual async Task <IStatusResponse> CreateAsync(
            CreatePersonRequest model, CancellationToken token = default)
        {
            model.ArgumentNullCheck(nameof(model));

            using (var scope = TransactionFactory.CreateTransaction())
            {
                var result = await service.CreateAsync(model, token);

                scope.Complete();

                return(result);
            }
        }
Exemplo n.º 2
0
        public virtual async Task <IStatusResponse> CreateAsync(
            CreatePersonRequest model, CancellationToken token = default)
        {
            model.ArgumentNullCheck(nameof(model));

            var entity = model.CreateEntity();

            context.Set <Person>().Add(entity);

            await context.SaveChangesAsync(token);

            await eventDispatcher.DispatchAsync(new Events.CreateEvent(entity));

            return(new StatusResponse(entity.Id));
        }