コード例 #1
0
ファイル: HomeController.cs プロジェクト: Sregey/GalaxyForum
        public ActionResult Topic(int id, int?page)
        {
            BllTopic topic = GetTopic(id, page);

            ViewBag.IsMyTopic = IsMyTopic(topic.Id);
            return(View(topic.ToTopicDitailsModel()));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: Sregey/GalaxyForum
        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())));
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: Sregey/GalaxyForum
        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);
        }
コード例 #4
0
 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(),
     });
 }
コード例 #5
0
 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));
 }
コード例 #6
0
        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."));
            }
        }
コード例 #7
0
 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));
 }
コード例 #8
0
 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()),
     });
 }
コード例 #9
0
 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,
     });
 }
コード例 #10
0
        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));
        }
コード例 #11
0
 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;
     }
 }
コード例 #12
0
        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;
            }
        }
コード例 #13
0
 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
         },
     });
 }
コード例 #14
0
ファイル: ForumConsoleApi.cs プロジェクト: Sregey/GalaxyForum
        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);
        }