public async Task <MessageModel <string> > Update(long id, [FromBody] TestModel model) { var data = new MessageModel <string>(); if (!id.Equals(model.Id)) { data.status = 202; data.msg = "传入Id与实体Id不一致"; return(data); } var entity = await _testServices.GetById(id); if (entity == null) { data.status = 204; data.msg = "未匹配到数据"; return(data); } entity.Name = model.Name; entity.Remark = model.Remark; entity.UpdateTime = DateTime.Now.ToLocalTime(); data.success = await _testServices.Update(entity); if (data.success) { data.success = true; data.msg = "更新成功"; return(data); } else { data.status = 202; data.msg = "更新失败"; return(data); } }
public IActionResult Put(int id, [FromBody] NewTestModel value) { return(Ok(_testService.Update(id, value))); }
public IHttpActionResult Update(TestUpdateReq Obj) { var result = _TestService.Update(Obj); return(ApiHelper.ReturnHttpAction(result, this)); }