Exemple #1
0
        public virtual async Task <IStatusResponse> UpdateAsync(
            UpdatePersonRequest 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
            {
                model.UpdateEntity(entity);

                await context.SaveChangesAsync(token);

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

                response = new StatusResponse(model.Id);
            }

            return(response);
        }
        public virtual async Task <IStatusResponse> UpdateAsync(
            UpdatePersonRequest model, CancellationToken token = default)
        {
            model.ArgumentNullCheck(nameof(model));

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

                scope.Complete();

                return(result);
            }
        }