public ActionResult Forum() { var section = MessageSectionService.GetAll() .FirstOrDefault(ms => ms.SysName == MessageSections.Forum); return(Section(section.MessageSectionID, null)); }
private ActionResult ForumMessages(long?messageID, List <int> sectionIds) { var messages = (sectionIds.Any() ? UserMessageService.GetAll().Where(um => sectionIds.Contains(um.MessageSectionID.Value)) : UserMessageService.GetAll().Where(um => um.ParentMessageID == messageID)) .OrderByDescending(m => m.CreateDate) .Take(CommonConst.MessageCount).ToList(); var title = string.Empty; if (sectionIds.Any()) { if (sectionIds.Count == 1) { var section = MessageSectionService.GetByPK(sectionIds.First()); title = section.Name; } else { title = "Сообщения форума"; } } else { var message = UserMessageService.GetByPK(messageID); if (message == null) { title = "Сообщение не найдено"; } } return(GetFeed(title, messages)); }
public ActionResult AllMessages(int sectionID) { var sections = _.List(sectionID); var messages = GetAllSectionsMessages(sections); var section = MessageSectionService.GetByPK(sectionID); return(GetFeed(section.Name + ": все сообщения", messages)); }
public ActionResult AddMessage(int sectionID) { var messageSection = MessageSectionService.GetByPK(sectionID); return(View(new EditMessageVM { MessageSection = messageSection, CannotAddMessageToClub = CheckCannotAddMessageToClub(messageSection) })); }
public ActionResult Section(int?sectionID, int?pageIndex) { var section = MessageSectionService.GetByPK(sectionID); if (section == null) { return(null); } if ((section.IsGraduateClubOrChildren) && !User.GetOrDefault(x => x.InRole(Role.GraduateClubAccess))) { return(BaseView(new PagePart("Доступ только для выпускников"))); } if (section.Children.Any()) { var model2 = new SectionListVM { MessageSections = section.Children .AsQueryable().IsActive().ToList(), User = User }; foreach (var messageSection in model2.MessageSections) { messageSection.MessageCount = MessageSectionService .SectionMessageCounts().GetValueOrDefault(messageSection .MessageSectionID); messageSection.LastMessageDate = MessageSectionService .SectionLastMessageDates().GetValueOrDefault(messageSection .MessageSectionID); } return(View(ViewNames.SectionList, model2)); } pageIndex = pageIndex ?? 1; var messages = UserMessageService.GetAll() .Where(um => um.MessageSectionID == sectionID && um.IsActive) .OrderByDescending(um => um.Children.Max(um2 => (DateTime?)um2.CreateDate) ?? um.CreateDate) .ToPagedList(pageIndex.Value - 1); var messageIds = messages.Select(x => x.UserMessageID).ToList(); var messageCounts = UserMessageService .GetAll(x => messageIds.Contains(x.UserMessageID)) .Select(x => new { x.UserMessageID, x.Children.Count }).ToList() .ToDictionary(x => x.UserMessageID, x => x.Count); var model = new SectionMessageListVM { Messages = messages, MessageCounts = messageCounts, Section = section, }; return(View(ViewNames.MessageList, model)); }
public ActionResult AddMessage(EditMessageVM model) { if (model.IsLoad == EditMessageVM.LoadImage) { model.MessageSection = MessageSectionService.GetByPK( model.MessageSection.MessageSectionID); return(ProcessImage(model)); } if (FluentValidate(model)) { var messageID = SaveMessage(model); return(RedirectToAction(() => Details(messageID, 1))); } model.MessageSection = MessageSectionService.GetByPK( model.MessageSection.MessageSectionID); return(View(model)); }