public async Task <IActionResult> Post([FromBody] yx_serviceitem value) { value.CreatedAt = DateTime.Now; value.UpdatedAt = DateTime.Now; value.IsValid = true; if (User.Identity is ClaimsIdentity identity) { value.CreatedBy = identity.Name ?? "test"; } _yxServiceitemRpt.Add(value); _yxServiceitemRpt.Commit(); return(new OkObjectResult(value)); }
public async Task <IActionResult> Put(int id, [FromBody] yx_serviceitem value) { var single = _yxServiceitemRpt.GetSingle(id); if (single == null) { return(NotFound()); } ObjectCopy.Copy(single, value, "name", "typeId", "unit", "itemCode", "integral", "remark", "price"); //更新字段内容 single.UpdatedAt = DateTime.Now; if (User.Identity is ClaimsIdentity identity) { single.CreatedBy = identity.Name ?? "test"; } _yxServiceitemRpt.Commit(); return(new NoContentResult()); }