Пример #1
0
        //
        // GET: /Topic/Details/5

        public ActionResult Details(Guid?id = null)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            ContentTopic contentTopic = db.ContentTopics.Include(c => c.ContentThread)
                                        .Include(c => c.MemberUser)
                                        .Include(c => c.ContentComments)
                                        .Where(c => c.Id == id.Value).SingleOrDefault();

            if (contentTopic == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new TopicCommentsViewModel()
            {
                Topic = contentTopic
            };

            viewModel.Post     = contentTopic.ContentComments.SingleOrDefault(x => x.Id == viewModel.Topic.FirstCommentId);
            viewModel.Comments = contentTopic.ContentComments.Where(x => x.Id != viewModel.Topic.FirstCommentId)
                                 .OrderBy(x => x.CreateTime)
                                 .ToList();

            return(View(viewModel));
        }
Пример #2
0
        //
        // GET: /Topic/Edit/5

        public ActionResult Edit(Guid?id = null)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            ContentTopic contentTopic = db.ContentTopics.Include(c => c.ContentThread)
                                        .Include(c => c.MemberUser)
                                        .Include(c => c.ContentComments)
                                        .Where(c => c.Id == id.Value).SingleOrDefault();

            if (contentTopic == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new TopicCommentsViewModel()
            {
                Topic = contentTopic
            };

            viewModel.Post     = contentTopic.ContentComments.SingleOrDefault(x => x.Id == viewModel.Topic.FirstCommentId);
            viewModel.Comments = contentTopic.ContentComments.Where(x => x.Id != viewModel.Topic.FirstCommentId).ToList();

            ViewBag.Threads = new SelectList(db.ContentThreads, "Id", "Name", viewModel.Topic.ThreadId);
            ViewBag.Users   = new SelectList(db.MemberUsers, "Id", "UserName", viewModel.Topic.UserId);
            return(View(viewModel));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            ContentTopic contenttopic = db.ContentTopics.Find(id);

            db.ContentTopics.Remove(contenttopic);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
        //
        // GET: /Topic/Delete/5

        public ActionResult Delete(Guid?id = null)
        {
            ContentTopic contenttopic = db.ContentTopics.Find(id);

            if (contenttopic == null)
            {
                return(HttpNotFound());
            }
            return(View(contenttopic));
        }
Пример #5
0
        public ActionResult Create(ContentTopic contenttopic)
        {
            if (ModelState.IsValid)
            {
                contenttopic.Id = Guid.NewGuid();
                db.ContentTopics.Add(contenttopic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ThreadId = new SelectList(db.ContentThreads, "Id", "Name", contenttopic.ThreadId);
            ViewBag.UserId   = new SelectList(db.MemberUsers, "Id", "UserName", contenttopic.UserId);
            return(View(contenttopic));
        }
Пример #6
0
        public ActionResult TopicItem(TopicViewModel topicViewModel)
        {
            ContentTopic   topic = db.ContentTopics.Find(topicViewModel.Topic.Id);
            ContentComment post  = db.ContentComments.Find(topic.FirstCommentId);

            topic.IsHidden = topicViewModel.Topic.IsHidden;
            topic.IsSticky = topicViewModel.Topic.IsSticky;
            topic.IsLocked = topicViewModel.Topic.IsLocked;

            db.SaveChanges();

            topicViewModel.Topic = topic;
            topicViewModel.Post  = post;

            return(PartialView("_TopicItem", topicViewModel));
        }
Пример #7
0
        public ActionResult CommentItem(TopicViewModel commentViewModel)
        {
            ContentComment commentItem = db.ContentComments.Find(commentViewModel.Post.Id);

            commentItem.IsHidden   = commentViewModel.Post.IsHidden;
            commentItem.IsSpam     = commentViewModel.Post.IsSpam;
            commentItem.IsLocked   = commentViewModel.Post.IsLocked;
            commentItem.IsSolution = commentViewModel.Post.IsSolution;

            db.SaveChanges();

            commentViewModel.Post = commentItem;
            ContentTopic topic = db.ContentTopics.Find(commentViewModel.Post.TopicId);

            commentViewModel.Topic = topic;

            return(PartialView("_CommentItem", commentViewModel));
        }
Пример #8
0
    void Update()
    {
        if (!_topicLoaded)
        {
            System.Diagnostics.Debug.WriteLine("Reading content");
            ContentData contentData = new ContentData();
            Task.WaitAll(Task.Run(async() =>
            {
                contentData = await ContentService.LoadContent();
            }));

            if (contentData.Files.Any())
            {
                System.Diagnostics.Debug.WriteLine("Content found");
            }
            ContentFile  firstFile  = contentData.Files.FirstOrDefault();
            ContentTopic firstTopic = firstFile?.Topics.FirstOrDefault();
            if (firstTopic != null)
            {
                System.Diagnostics.Debug.WriteLine("Unzipping content ...");
                string extractedTo = string.Empty;
                Task.WaitAll(Task.Run(async() =>
                {
                    extractedTo = await ContentService.UnzipContent(firstFile.Filename);
                }));
                if (extractedTo != string.Empty)
                {
                    string url = $"ms-appdata:///local/Content/{firstTopic.LandingPage}";
                    //string url = Path.Combine(extractedTo, firstTopic.LandingPage);

                    System.Diagnostics.Debug.WriteLine($"Loading Url: {url}");
                    _webViewPrefab.WebView.LoadUrl(url);
                    System.Diagnostics.Debug.WriteLine($"Url loaded.");
                    _topicLoaded = true;
                }
            }
        }
    }