public async Task <IActionResult> CreateElement([FromBody] CoreElementViewModel element) { if (!_healthService.IsStateHealthy) { return(StatusCode(StatusCodes.Status500InternalServerError)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var newElement = await _persistentStorageService.CreateAsync(element); return(CreatedAtRoute("GetElementId", new CoreElementViewModel { Id = newElement }, newElement.ToString())); } catch { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <IActionResult> CreateCustomer([FromBody] CustomerViewModel customer) { if (!_healthService.IsStateHealthy) { return(StatusCode(StatusCodes.Status500InternalServerError)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var newCustomer = await _persistentStorageService.CreateAsync(customer); return(CreatedAtRoute("GetCustomerId", new CustomerViewModel { Id = newCustomer }, newCustomer.ToString())); } catch { return(StatusCode(StatusCodes.Status500InternalServerError)); } }