示例#1
0
        public CustomerAddCommand(Application.Models.NewCustomer newCustomer)
        {
            if (newCustomer == null)
            {
                throw new ArgumentNullException(nameof(newCustomer));
            }

            this.NewCustomer = newCustomer;
        }
        public async Task <IActionResult> CreateCustomer([FromBody] Application.Models.NewCustomer customer)
        {
            if (customer == null)
            {
                throw new ArgumentNullException(nameof(customer));
            }

            var command = new CustomerAddCommand(customer);
            var result  = await this._mediator.Send(command);

            if (result != null)
            {
                return(new OkObjectResult(result.Result));
            }

            return(new BadRequestResult());
        }