Пример #1
0
        public async Task <IActionResult> Index()
        {
            var topicsViewModel = new TopicsViewModel();
            var topics          = await _context.Topic.Select(o => o).ToListAsync();

            foreach (var topicItem in topics)
            {
                var tmpTopicViewModel = new TopicViewModel
                {
                    TopicId        = topicItem.TopicId,
                    PostCount      = topicItem.PostCount,
                    Title          = topicItem.Title,
                    OriginalPoster = topicItem.OriginalPoster
                };
                var posts = await _context.Post
                            .Where(o => o.TopicId == topicItem.TopicId)
                            .Select(u =>
                                    new PostViewModel {
                    Poster    = u.Poster,
                    Body      = u.Body,
                    TimeStamp = u.TimeStamp
                }).ToListAsync();

                tmpTopicViewModel.Posts = posts;

                topicsViewModel.Topics.Add(tmpTopicViewModel);
            }

            return(View(topicsViewModel));
        }
Пример #2
0
        // GET: Admin

        /// <summary>
        /// Список тем на форуме
        /// </summary>
        /// <param name=""></param>
        public ActionResult TopicsList()
        {
            try
            {
                List <TopicsViewModel> topics = new List <TopicsViewModel>();
                var SectionsBLL = Data.GetSections();
                ViewBag.EmptySection = new string[SectionsBLL.Count()];
                foreach (var s in SectionsBLL)
                {
                    var TopicsBLL = Data.GetTopicsForAdmin(s.SectionID);
                    if (TopicsBLL.Count() == 0)
                    {
                        TopicsViewModel topic = new TopicsViewModel();
                        topic.SectionID    = s.SectionID;
                        topic.SectionName  = s.SectionName;
                        topic.EmptySection = "В разделе ещё нет тем";
                        topics.Add(topic);
                    }
                    else
                    {
                        foreach (var t in TopicsBLL)
                        {
                            TopicsViewModel topic = new TopicsViewModel();
                            topic.SectionID    = s.SectionID;
                            topic.SectionName  = s.SectionName;
                            topic.TopicID      = t.TopicID;
                            topic.TopicName    = t.TopicName;
                            topic.AuthorName   = t.Name;
                            topic.CreateDate   = t.CreateDate;
                            topic.MessageCount = t.MessageCount;
                            var u = Data.LastMessageForAdmin(t.TopicID);
                            topic.Name     = u.Name;
                            topic.SendDate = u.RegistrationDate;
                            var messages = Data.GetMessages(t.TopicID);
                            foreach (var m in messages)
                            {
                                if (m.StatusID == 0)
                                {
                                    topic.InvisibleMessages++;
                                }
                            }
                            topics.Add(topic);
                        }
                    }
                }
                return(PartialView(topics));
            }
            catch (ValidationException ex)
            {
                return(Content(ex.Message));
            }
        }
Пример #3
0
        private void StartNavigationService(PersonRecord model)
        {
            NavigationService navi = new NavigationService();

            TopicsViewModel  = new TopicsViewModel(navi, model);
            MapPageViewModel = new MapPageViewModel(navi, model);

            TopicsPage = new NavigationPage(new TopicsPage());
            MapPage    = new MapPage();

            navi.Navi        = TopicsPage.Navigation;
            navi.CurrentPage = TopicsPage;
            MainPage         = TopicsPage;
        }
Пример #4
0
        public async Task <ActionResult> GetTopicArticlesAsync(TopicsViewModel topic)
        {
            ViewBag.ActiveTopicId = topic.TopicId;
            var artiklesEng = await FindArtikleEngineService.FindByTopicIdAsync(topic.TopicId);

            var artikles = Mapper.Map <List <ArticleViewModel> >(artiklesEng);
            // var topic=
            ArticlesViewModel articlesViewModel = new ArticlesViewModel()
            {
                Articles = artikles, Topic = topic
            };

            //return View("~/Areas/Article/Views/Article/Index.cshtml", artikles);
            return(View("~/Views/Article/Artikles.cshtml", articlesViewModel));
        }
Пример #5
0
        public ActionResult AllArtikle()
        {
            var artiklesEng = ArticleEngineService.GetAllAsync(0, 100).Result;
            var artikles    = Mapper.Map <List <ArticleViewModel> >(artiklesEng);
            var topic       = new TopicsViewModel()
            {
                Name = "All artikles", Description = "For Admin", TopicId = 0
            };
            ArticlesViewModel articlesViewModel = new ArticlesViewModel()
            {
                Articles = artikles, Topic = topic
            };

            return(View("~/Views/Article/Artikles.cshtml", articlesViewModel));
        }
Пример #6
0
            public ActionResult Index(TopicsViewModel newTopic)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        TopicsDTO TopicBLL = new TopicsDTO();
                        TopicBLL.SectionID = newTopic.SectionID;
                        TopicBLL.TopicName = newTopic.TopicName;
                        TopicBLL.TopicText = newTopic.TopicText;
                        TopicBLL.UserID    = newTopic.UserID;
                        Data.CreateTopic(TopicBLL);

                        return(RedirectToAction("Index"));
                    }
                    else

                    {
                        var SectionsBLL = Data.GetSections();

                        int length = SectionsBLL.Count();
                        ViewBag.SectionID   = new int[length];
                        ViewBag.SectionName = new string[length];

                        for (int i = 0; i < length; i++)
                        {
                            ViewBag.SectionID[i]   = SectionsBLL.ElementAt(i).SectionID;
                            ViewBag.SectionName[i] = SectionsBLL.ElementAt(i).SectionName;
                        }
                        if (User.Identity.Name != "")
                        {
                            var curentUser = Data.GetCurentUser(User.Identity.Name);
                            ViewBag.Avatar = curentUser.Avatar;
                            ViewBag.Name   = curentUser.Name;
                            ViewBag.UserID = curentUser.UserID;
                        }
                        ViewBag.TopicName = newTopic.TopicName;
                        ViewBag.TopicText = newTopic.TopicText;

                        return(View());
                    }
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("DalError", ex.Message);
                    return(View(newTopic));
                }
            }
Пример #7
0
        public IEnumerable <TopicsViewModel> GetTopicsViewModel()
        {
            var viewModels = new List <TopicsViewModel>();

            foreach (var topic in this.Context.Topics.Entities.Take(10))
            {
                var model = new TopicsViewModel()
                {
                    Id           = topic.Id,
                    TopicTitle   = topic.Title,
                    CategoryName = topic.Category.Name,
                    Author       = topic.Author.Username,
                    DateTime     = topic.PublishDate,
                    RepliesCount = topic.Replies.Count
                };

                viewModels.Add(model);
            }

            return(viewModels);
        }
Пример #8
0
 public TopicsPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new TopicsViewModel();
 }