0

I have this method where i first check if an user is admin, if you are admin you will get a list of users from a database. But VS is telling me i have to put another return outside the IF admin brackets, im totally lost here what i should return? Something in the style of that you cant return anything because you are not admin

public static IEnumerable<User> FindUser(int AdminId, string Keyword)
{
 using (var db = new DatabaseContext())
 {
  var admin = db.Users.Where(a => a.Id == AdminId).Select(a => a.IsAdmin).FirstOrDefault();
  if (admin == true)
  {
   var FindUser = db.Users.Where(u => u.Name.Contains(Keyword)).OrderBy(u => u.Name).ToList();
   return FindUser;
  }
   return something here(???)
  }
 }
ScreamoIsDead
  • 157
  • 1
  • 1
  • 13

1 Answers1

2

What you are looking for is

return Enumerable.Empty<User>();

dariogriffo
  • 4,148
  • 3
  • 17
  • 34