public async Task <ActionResult> Register(CustomerBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await createCustomerCommand.Execute(model); return(Ok()); }
public async Task <IActionResult> PostCustomer([FromBody] CreateCustomerModel customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _createCustomerCommand.Execute(customer); return(CreatedAtAction("GetCustomer", new { id = customer.CustomerId }, customer)); }
private Customer GetOrCreateCustomer() { var customer = _database.Customers.Where(c => c.FirstName == _model.CustomerFirstName && c.LastName == _model.CustomerLastName).FirstOrDefault(); if (customer == null) { var createCustomerModel = new CreateCustomerModel(); createCustomerModel.FirstName = _model.CustomerFirstName; createCustomerModel.LastName = _model.CustomerLastName; customer = _customerCommand.Execute(createCustomerModel); } return(customer); }
public async Task <IActionResult> Create([FromBody] CreateCustomerModel customer) { if (customer == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _createCustomerCommand.Execute(customer); return(CreatedAtRoute("Create", new { customer.Id }, customer)); }
public async Task <ActionResult> Post([FromBody] CreateCustomerModel model) { if (model == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _customerCreateContext.Execute(model); return(CreatedAtRoute("Create", new { model.Id }, model)); }
public async Task <IActionResult> PostCustomer([FromBody] CreateCustomerModel customer) { await _createCustomerCommand.Execute(customer); return(CreatedAtAction("GetCustomer", new { id = customer.CustomerId }, customer)); }