private async Task <string> ModifyState(UserState userState) { using var db = new YGBContext(); DB.Tables.User user = await db.Users.FirstOrDefaultAsync(u => u.Id == Id); if (user is null) { return(USER_NOT_EXIST); } int value = (int)userState; string description = userState.GetDescription(); if (user.State == value) { return($"用户已是{description}的状态,不能重复{description}"); } user.State = value; int count = await db.SaveChangesAsync(); if (count == 1) { return(""); } return("启用失败"); }