public static DetailsViewModel CreateViewModel(Question q) { var model = new DetailsViewModel { Question = q, Posts = q.Responses.Select(DetailsPostViewModel.CreateViewModel), }; return model; }
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 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 static EditViewModel CreateViewModel(Question q, IEnumerable<Category> categories, IEnumerable<string> users) { var model = new EditViewModel(); model.Details = DetailsViewModel.CreateViewModel(q); model.AssignedTo = q.TakenBy; model.CategoryId = q.CategoryId.GetValueOrDefault(); model.QuestionId = q.Id; model.CategoryList = categories.Select(c => new SelectListItem { Selected = false, Text = c.CategoryName, Value = c.Id.ToString() }); model.AssignmentList = users.Select(u => new SelectListItem {Selected = false, Text = u, Value = u}); return model; }
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; }
public void SaveQuestion(Question question) { _container.Questions.AddObject(question); _container.SaveChanges(); }
public ReplyViewModel(Question question) { OriginalQuestion = question; Reply = new Post {Subject = "Re: " + question.Subject}; }
public ActionResult QuestionActionButtons(Question question) { return View(question); }
public ActionResult Take(Question question) { var questionToEdit = _repositories.Questions.Get().WithId(question.Id); if (questionToEdit.IsTaken()) return View("AlreadyTaken"); questionToEdit.Take(UserModel.Current.UserName); _repositories.Questions.SaveChanges(); return RedirectToAction("Details", new RouteValueDictionary(new {id = question.Id})); }
/// <summary> /// Deprecated Method for adding a new object to the Questions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToQuestions(Question question) { base.AddObject("Questions", question); }
/// <summary> /// Create a new Question object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="subject">Initial value of the Subject property.</param> /// <param name="body">Initial value of the Body property.</param> /// <param name="createdBy">Initial value of the CreatedBy property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> /// <param name="countyId">Initial value of the CountyId property.</param> public static Question CreateQuestion(global::System.Int32 id, global::System.String subject, global::System.String body, global::System.String createdBy, global::System.DateTime createdDate, global::System.Int32 countyId) { Question question = new Question(); question.Id = id; question.Subject = subject; question.Body = body; question.CreatedBy = createdBy; question.CreatedDate = createdDate; question.CountyId = countyId; return question; }
public ActionResult Ask(Question question) { if (this.ModelState.IsValid) { try { question.CreatedBy = UserModel.Current.UserName; question.CreatedDate = DateTime.Now; question.CountyId = _questionRepository.Counties.WithCounty(UserModel.Current.UserProfile.County).First().Id; _questionRepository.SaveQuestion(question); var detailsUrl = Url.AttorneyQuestionDetailsLink(question.Id); var unsubscribeUrl = ConfigSettings.SiteUrl.TrimEnd('/') + Url.Action("Unsubscribe", "Attorney", new {id = question.CategoryId}); _emailService.SendEmailFor(question.Category, new SubscriptionEmail(question.Category.ShortDescription, question.CourtDateAsShortString, question.Subject, question.Body, detailsUrl, unsubscribeUrl)); _auditor.Audit(_currentUser.UserName, question.Id); return View("QuestionSubmitted"); } catch (Exception e) { this.ModelState.AddModelError("*", e.Message); } } ViewData["categories"] = _questionRepository.Categories; return View(question); }