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 static MvcRow BeginRowForCoding(this HtmlHelper helper, Question question) { DateTime created = question.CreatedDate; var tagBuilder = new TagBuilder("tr"); var cssClass = question.IsClosed() ? "Closed" : created > DateTime.Now.AddDays(-10) ? "Current" : created < DateTime.Now.AddDays(-25) ? "Urgent" : "Overdue"; tagBuilder.AddCssClass(cssClass); helper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); var row = new MvcRow(helper.ViewContext); return row; }
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; }