예제 #1
0
        public async Task <IActionResult> Put(int id, PutCustomerCommand data)
        {
            data.Data.Attributes.Id = id;
            var result = await _mediatr.Send(data);

            return(Ok(result));
        }
        public async Task <IActionResult> Put(int ID, PutCustomerCommand data)
        {
            data.Dataa.Attributes.id = ID;
            var result = await meciater.Send(data);

            return(Ok(result));
        }
        public async Task <PutCustomerByIdResponse> Handle(PutCustomerByIdRequest request, CancellationToken cancellationToken)
        {
            if (request.AuthenticatorRole == AppRole.Employee)
            {
                return(new PutCustomerByIdResponse()
                {
                    Error = new ErrorModel(ErrorType.Unauthorized)
                });
            }

            var query = new GetCustomerQuery()
            {
                Id        = request.Id,
                CompanyId = request.AuthenticatorCompanyId
            };
            var customer = await queryExecutor.Execute(query);

            if (customer == null)
            {
                return(new PutCustomerByIdResponse()
                {
                    Error = new ErrorModel(ErrorType.NotFound)
                });
            }

            var updateCustomer = mapper.Map <Customer>(request);

            updateCustomer.CompanyId = request.AuthenticatorCompanyId;

            var command = new PutCustomerCommand
            {
                Parameter = updateCustomer
            };
            var updatedCustome = await commandExecutor.Execute(command);

            var response = mapper.Map <CustomerDto>(updatedCustome);

            return(new PutCustomerByIdResponse
            {
                Data = response
            });
        }
예제 #4
0
 public async Task <ActionResult <PutCustomerCommandResponse> > Put(PutCustomerCommand request, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await Mediator.Send(request, cancellationToken));
 }
예제 #5
0
 public async Task <ActionResult <PutCustomerCommandResponse> > Put([FromRoute] int customerID, [FromBody] PutCustomerCommand request)
 {
     request.Project(x => x.CustomerID = customerID);
     return(await Send(request));
 }