public async Task <IActionResult> CreateElementAsync([FromBody] ElementCreationModel creation) { _logger.LogInformation($"(Element creation) Element creation requested => '{JsonConvert.SerializeObject(creation)}'"); var element = await _elementRepository.CreateAsync(creation); return(Created($"http://{Request.Host.Value}/{ControllerConstants.ElementControllerRoute}/{element.Id}", element)); }
public async Task <ElementModel> CreateAsync(ElementCreationModel model) { var element = new ElementModel { Description = model.Description, Name = model.Name }; _logger.LogInformation($"(Element '{element.Id}') Creating element model => '{JsonConvert.SerializeObject(model)}'"); using (var context = new ExampleContext(_options)) { await context.Elements.AddAsync(element); } _logger.LogInformation($"(Element '{element.Id}') Element model successfully created"); return(element); }