public async Task <bool> Edit(UserInfo userInfo) { if (UserInfo.Validate(userInfo).All(u => u.IsSuccess)) { if (userInfo.UserId.IsEmpty()) { var current = UserDb.GetSingle(ur => ur.UserName == userInfo.UserName); if (current.IsNull()) { userInfo.UserId = Guid.NewGuid(); return(await UserDb.AsInsertable(userInfo).ExecuteCommandAsync() > 0); } else { return(false); } } else { return(await UserDb.AsUpdateable(userInfo).ExecuteCommandAsync() > 0); } } return(false); }