public async Task <IActionResult> AddNewCustomer([FromBody] AddNewCustomerCommand request) { var response = await Mediator.Send(request); if (!string.IsNullOrWhiteSpace(response)) { return(BadRequest(response)); } return(Created("AddNewCustomer", new { })); }
public Task<AddNewCustomerResponse> addNewCustomer(AddNewCustomerRequest request) { AddNewCustomerCommand command = new AddNewCustomerCommand( request.Name, request.Note, request.CartCode, request.PhoneNumber, request.Email, request.Code, request.Status, request.Address.City, request.Address.Country, request.Address.District, request.Address.Street, request.Address.StreetNumber, request.Address.Lat.ToString(), request.Address.Lng.ToString() ); Task<object> Customer = (Task<object>)Bus.SendCommand(command); RabbitMQBus.Publish(command); AddNewCustomerResponse response = new AddNewCustomerResponse(); response = Common<AddNewCustomerResponse>.checkHasNotification(_notifications, response); if (response.Success) { CustomerModel CustomerModel = (CustomerModel)Customer.Result; //them bao gia AddNewQuotationRequest request2 = new AddNewQuotationRequest() { customer_code = CustomerModel.Code, date = DateTime.Now }; _QuotationAppService.addNewQuotation(request2); response.Data = CustomerModel.ID; } return Task.FromResult(response); }