public async Task <IActionResult> Put(int id, [FromBody] fw_cusgoods value) { var single = _fwCusgoodsRpt.GetSingle(id); if (single == null) { return(NotFound()); } ObjectCopy.Copy <fw_cusgoods>(single, value, new string[] { "TypeName", "GoodsName", "GoodsPrice", "HouseCode", "OrderNo", "CusName", "Mobile", "Remark" }); single.UpdatedAt = DateTime.Now; //更新字段内容 if (User.Identity is ClaimsIdentity identity) { if (!string.IsNullOrEmpty(value.TakeBy)) { single.TakeBy = identity.Name ?? "test"; single.TakeTime = DateTime.Now; } else { single.CreatedBy = identity.Name ?? "test"; } } _fwCusgoodsRpt.Commit(); return(new NoContentResult()); }
public async Task <IActionResult> Post([FromBody] fw_cusgoods value) { value.CreatedAt = DateTime.Now; value.UpdatedAt = DateTime.Now; value.IsValid = true; if (User.Identity is ClaimsIdentity identity) { value.CreatedBy = identity.Name ?? "test"; } _fwCusgoodsRpt.Add(value); _fwCusgoodsRpt.Commit(); return(new OkObjectResult(value)); }