Exemple #1
0
        public ActionResult CreateTopic()
        {
            var topic = new CreateEditTopicModel();

            topic.Sections = topicService.GetAllSections()
                             .Select(s => new SelectListItem {
                Text = s.Name, Value = s.Id.ToString()
            });
            return(View(topic));
        }
Exemple #2
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));
 }
 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));
 }
Exemple #4
0
 public static BllTopic ToBllTopic(this CreateEditTopicModel topic)
 {
     return(new BllTopic
     {
         Id = topic.Id,
         //Author = new BllUser { Id = topic.AuthorId },
         Title = topic.Title,
         Text = topic.Text,
         Section = new BllSection()
         {
             Id = Int32.Parse(topic.Section)
         },
     });
 }
        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 ActionResult DeletTopic(CreateEditTopicModel topic)
 {
     topicService.DeleteTopic(topic.Id);
     return(RedirectToAction("Topics"));
 }
 public ActionResult RejectTopic(CreateEditTopicModel topic)
 {
     return(ChangeTopicState(topic, StatusEnum.Rejected));
 }
 public ActionResult AcceptTopic(CreateEditTopicModel topic)
 {
     return(ChangeTopicState(topic, StatusEnum.Accepted));
 }