public async Task Add_ReturnsNewItem() { var newItem = await _valueService.Add(new ValueModel { Name = "new value" }); Assert.IsNotNull(newItem); Assert.IsTrue((newItem as IValueModel).Name == "new value"); Assert.IsTrue((newItem as IValueModel).Id > 2); }
public IActionResult Post([FromBody] NewValueViewModel newValue) { Value value = _valueService.Add(new Value() { Content = newValue.Content }); value.AddSelfLink(_uriHelper, "get", "Values"); value.AddLink(_uriHelper, "delete", "Values", "del", new { id = value.Id }); return(new CreatedAtActionResult("Get", "Values", new { id = value.Id }, value)); }
public async Task <IActionResult> Post([FromBody] NewValuesViewModel value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var createdObject = await _valueService.Add(new models.ValueModel { Name = value.Name }); return(Created($"api/Values/", value.Name)); }
public ActionResult <ValueEntity> AddValue([FromBody] ValueEntity value) { try { return(CreatedAtAction("GET", _services.Add(value))); } catch (Exception e) { return(BadRequest(new ErrorMessage() { message = e.Message, code = ErrorCodes.NotCreatedModel })); } }
public Value Post([FromBody] Value value) { value = _valueService.Add(value); return(value); }