Make a custom class to hold all three values, and return it. Get rid of the "out" parameters.
Reed Copsey
2009-08-15 19:59:20
Make a custom class to hold all three values, and return it. Get rid of the "out" parameters.
How about this??
public class LoginOutput{
private bool _isLoginSuccess=false;
public bool IsLoginSuccess{/*Usual get set block*/}
private string _successRedirectUrl = String.Empty();
public string SuccessRedirectUrl{/*Usual get set block*/}
public IValidationDictionary ValidationResultDict{/*Usual get set block*/}
}
//your method now could be
public LoginOutput Login(string username, string password){
// your logic goes here
}
Questions:
Is the redirect URL different for different users? - I would say it shouldn't be, but if it is different, the decision shouldn't be in your business layer. This is UI logic and should be there.
What's your IValidationDictionary interface? You can probably just use it directly in your UI logic:
public IValidationDictionary Login(string user, string password);
var user = "bob";
var validator = Login(user, "password");
if (validator.IsValid)
Response.Redirect(GetUserPage(user));
else
HandleLoginError();
Note that GetUserPage() should not be a database lookup or anything else complicated. Again, this should be simple UI logic, something like:
public string GetUserPage(string user)
{
return "/MyPage/" + user;
}