public UserErrorModel LoginUser(LoginModel login)
 {
     return Service.LoginUser(login);
 }
 public UserErrorModel LoginUser(LoginModel login)
 {
     var errors = new UserErrorModel();
     if (login == null)
     {
         errors.Messages.Add("Invalid data.");
         return errors;
     }
     var email = login.Username;
     var password = login.Password;
     if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
     {
         errors.Messages.Add("Invalid username/password.");
         return errors;
     }
     var user =
         DbContext.GetUsers()
             .SingleOrDefault(u => string.Equals(email, u.Email, StringComparison.OrdinalIgnoreCase));
     if (user != null && string.Equals(user.Password, password, StringComparison.Ordinal))
     {
         errors.UserId = user.UserId;
         errors.IsProvider = DbContext.GetProviders().Any(p => p.ProviderId == user.UserId);
     }
     else
     {
         errors.Messages.Add("Invalid username/password.");
     }
     return errors;
 }