public async Task <int> Delete(int id) { var power = await db.Power.FindAsync(id); db.Remove(power); return(await db.SaveChangesAsync()); }
public async Task <int> Delete(int id) { var role = await db.Role.FindAsync(id); if (role.EmpRole.Count > 0 || role.UsergroupRole.Count > 0) { throw new WeixiaoException("角色已经被分配使用,不能删除"); } db.Remove(role); return(await db.SaveChangesAsync()); }