public async Task<JsonResult> ChangeField([FromForm] ChangeFieldVm info) { var result = new ResultJsonNoDataInfo(); var respositoryResult = await AccountRespository.ChangeField(info); if (respositoryResult.Item1) { result.Status = ResultConfig.Ok; result.Info = string.Empty; } else { result.Status = ResultConfig.Ok; result.Info = string.IsNullOrEmpty(respositoryResult.Item2) ? ResultConfig.FailMessage : respositoryResult.Item2; } return Json(result); }
/// <summary> /// 更改用户的属性 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <Tuple <bool, string> > ChangeField(ChangeFieldVm model) { if (model == null || string.IsNullOrEmpty(model.Field) || string.IsNullOrEmpty(model.Value) || model.Tid < 1) { return(new Tuple <bool, string>(false, Tip.BadRequest)); } IUpdatable <SystemUsers> updateQuery = this.Entity.Where(r => r.Tid.Equals(model.Tid)) .Set2(model.Field, model.Value) .Set(r => r.DataChangeLastTime, DateTime.Now); var updateResult = await updateQuery.UpdateAsync() > 0; if (!updateResult) { return(new Tuple <bool, string>(false, Tip.UpdateError)); } return(new Tuple <bool, string>(true, string.Empty)); }