public ActionResult Topic(int id, int?page) { BllTopic topic = GetTopic(id, page); ViewBag.IsMyTopic = IsMyTopic(topic.Id); return(View(topic.ToTopicDitailsModel())); }
public ActionResult _Comments(int id, int?page) { BllTopic topic = GetTopic(id, page); ViewBag.IsMyTopic = IsMyTopic(topic.Id); return(PartialView(topic.Comments .Select(c => c.ToCommentModel()))); }
private BllTopic GetTopic(int id, int?page) { BllTopic topic = topicService.GetTopic(id); topic.Comments = this.GetItemsOnPage( topic.Comments.OrderBy(c => c.Date), page, COMMENTS_PER_PAGE); return(topic); }
public static CreateEditTopicModel ToCreateEditTopicModel(this BllTopic bllTopic) { return(new CreateEditTopicModel { Id = bllTopic.Id, //AuthorId = bllTopic.Author.Id, Title = bllTopic.Title, Text = bllTopic.Text, Section = bllTopic.Section.Id.ToString(), }); }
public ActionResult CreateTopic(CreateEditTopicModel topic) { if (ModelState.IsValid) { BllTopic bllTopic = topic.ToBllTopic(); bllTopic.Author = userService.GetUser(User.Identity.Name); topicService.AddTopic(bllTopic); return(RedirectToAction("Topics")); } return(View(topic)); }
public ActionResult GetRawTopic() { BllTopic topic = topicService.GetRawTopic(); if (topic != null) { return(RedirectToAction("EditTopic", new { id = topic.Id })); } else { return(View("Info", (object)"All topics are processed.")); } }
private ActionResult ChangeTopicState(CreateEditTopicModel topic, StatusEnum status) { if (ModelState.IsValid) { BllTopic bllTopic = topic.ToBllTopic(); bllTopic.Status = new BllStatus { Id = (int)status }; topicService.UpdateTopic(bllTopic); return(RedirectToAction("Topic", "Home", new { id = topic.Id })); } return(View("EditTopic", topic)); }
public static TopicDitailsModel ToTopicDitailsModel(this BllTopic bllTopic) { return(new TopicDitailsModel { Id = bllTopic.Id, Title = bllTopic.Title, Author = bllTopic.Author?.ToShortUserModel(), Date = bllTopic.Date, IsAnswered = bllTopic.IsAnswered, Text = bllTopic.Text, Comments = bllTopic.Comments.Select(c => c.ToCommentModel()), }); }
public static TopicListModel ToTopicListModel(this BllTopic bllTopic) { return(new TopicListModel { Id = bllTopic.Id, Title = bllTopic.Title, AuthorLogin = bllTopic.Author?.Login, Date = bllTopic.Date, IsAnswered = bllTopic.IsAnswered, SectionName = bllTopic.Section.Name, SectionId = bllTopic.Section.Id, Status = bllTopic.Status.Name, }); }
public ActionResult EditTopic(int id) { BllTopic bllTopic = topicService.GetTopic(id); bllTopic.Status = new BllStatus { Id = (int)StatusEnum.Processed }; topicService.UpdateTopic(bllTopic); CreateEditTopicModel topic = bllTopic.ToCreateEditTopicModel(); topic.Sections = topicService.GetAllSections() .Select(s => new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); return(View(topic)); }
public void AddTopic(BllTopic topic) { topic.Date = DateTime.Now; topic.Status = new BllStatus() { Id = (int)StatusEnum.Raw }; try { topicRepository.Add(topic.ToDalTopic()); } catch (InvalidOperationException e) { logger.Warn(e.Message); throw; } }
public void UpdateTopic(BllTopic topic) { DalTopic dalTopic = topicRepository.First(t => t.Id == topic.Id); dalTopic.Title = topic.Title; dalTopic.Text = topic.Text; dalTopic.Status.Id = topic.Status.Id; dalTopic.Section.Id = topic.Section.Id; try { topicRepository.Update(dalTopic); } catch (InvalidOperationException e) { logger.Warn(e.Message); throw; } }
public static DalTopic ToDalTopic(this BllTopic bllTopic) { return(new DalTopic { Id = bllTopic.Id, Title = bllTopic.Title, Text = bllTopic.Text, Date = bllTopic.Date, IsAnswered = bllTopic.IsAnswered, Section = bllTopic.Section.ToDalSection(), Author = new DalUser { Id = bllTopic.Author.Id }, Status = new DalStatus { Id = bllTopic.Status.Id }, }); }
private void AddTopic(string[] args) { if (!IsAutorize()) { PrintError(NotAutorizedError); return; } Sections(null); var topic = new BllTopic { Section = new BllSection { Id = ReadInt("Section") }, Title = ReadString("Title"), Text = ReadString("Text"), Author = me, }; topicService.AddTopic(topic); MyTopics(null); }