public IActionResult Post([FromBody] ValueDto value) { if (value.Id.HasValue) { var problemDetails = (new MyProblemDetails() { Status = StatusCodes.Status400BadRequest, Title = "ID不可输入", Type = $"http://xxxxx/value/post/IdForbidden", Detail = "创建资源时,系统会自动生成ID,请不要输入ID。" }); return(new MyProblemDetailsActionResult(problemDetails)); } if (!long.TryParse(value.No, out var noValue)) { throw new Exception($"编号必须是数值"); } value.Id = new Random().Next(1, 1000); return(this.Ok(value)); }
public void Put(int id, [FromBody] ValueDto value) { }