public bool CanMarkAsAnswer(Question question, string userName) { if(question.IsClosed()) { ErrorMessage = "Question is already closed"; return false; } if (question.IsOwner(userName) || question.IsTaker(userName) || _roles.IsUserInRole(userName, UserRoles.Administrators)) return true; ErrorMessage = "You do not have access to mark this question as answered"; return false; }
public bool CanTake(Question question, string userName) { if(!question.IsTaken()) return true; if(!question.IsTaker(userName)) { ErrorMessage = "The question you have selected has been taken by another attorney and is no longer available"; return false; } ErrorMessage = "You have already taken this question"; return false; }
public bool HasReplyAccess(Question question, string userName) { if(question.IsClosed()) { ErrorMessage = "Question is closed"; return false; } if(_roles.IsUserInRole(userName, UserRoles.Administrators)) return true; if(question.IsTaker(userName)) return true; if (!question.IsTaker(userName)) ErrorMessage = "The question must be taken before replying or it has already been taken by someone else"; return false; }