Ejemplo n.º 1
0
        public async Task <MutationInfo> Remove([Inject] IMediator mediator, [Inject] IRequestInfo requestInfo, NonNull <RemoveSupplierParameters> parameters)
        {
            var command = new RemoveSupplierCommand
            {
                Id      = parameters.Value.Id,
                Headers = new CommandHeaders(correlationId: Guid.NewGuid(), identity: requestInfo.Identity, remoteIpAddress: requestInfo.IpAddress)
            };

            var result = await mediator.Send(command);

            return(MutationInfo.FromCommand(command));
        }
Ejemplo n.º 2
0
        public async Task <string> Handle(RemoveSupplierCommand cmd)
        {
            var supplier = (await supplierRepository.QuerySupplier(new SupplierSearchQuery
            {
                SupplierId = cmd.SupplierId,
            })).Items.SingleOrDefault(m => m.Id == cmd.SupplierId);

            if (supplier == null)
            {
                throw new NotFoundException($"Supplier {cmd.SupplierId} not found", cmd.SupplierId);
            }

            supplier.Team.Id         = null;
            supplier.SharedWithTeams = Array.Empty <Resources.Suppliers.Team>();
            var res = await supplierRepository.ManageSupplier(new SaveSupplier { Supplier = supplier });

            return(res.SupplierId);
        }