/// <summary> /// 同步执行更新操作。 /// </summary> public static void Update(this IUpdatable updatable) { if (updatable == null) { throw new ArgumentNullException(nameof(updatable)); } Task.WaitAll(updatable.UpdateAsync()); }
/// <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)); }