Exemplo n.º 1
0
        public void AddTopic(string title)
        {
            Topic topic = new Topic
            {
                Title       = title,
                DateCreated = DateTime.Now,
                UserID      = HttpContext.Current.User.Identity.GetUserId()
            };

            TopicsRepository.AddOrUpdateTopic(topic);
            //get all topics
            GetTopics();
        }
Exemplo n.º 2
0
        public void AddComment(int id, string comment)
        {
            Comment c = new Comment
            {
                TopicID     = id,
                Answer      = comment,
                UserID      = HttpContext.Current.User.Identity.GetUserId(),
                DateCreated = DateTime.Now,
            };

            TopicsRepository.AddComment(c);

            GetComments(id);
        }
Exemplo n.º 3
0
 public ActionResult AddTopic(string topic)
 {
     if (!string.IsNullOrEmpty(topic))
     {
         Topic t = new Topic
         {
             Title       = topic,
             DateCreated = DateTime.Now,
             UserID      = User.Identity.GetUserId()
         };
         TopicsRepository.AddOrUpdateTopic(t);
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 4
0
 public ActionResult AddComment(int topicid, string comment)
 {
     if (!string.IsNullOrEmpty(comment))
     {
         Comment c = new Comment
         {
             TopicID     = topicid,
             UserID      = User.Identity.GetUserId(),
             Answer      = comment,
             DateCreated = DateTime.Now
         };
         TopicsRepository.AddComment(c);
     }
     return(RedirectToAction("Details", new { id = topicid }));
 }
Exemplo n.º 5
0
        public void GetTopics()
        {
            var topics = TopicsRepository.GetTopics();

            var jsonRes = (from t in topics
                           select new
            {
                Id = t.TopicID,
                Title = t.Title,
                DatePosted = t.DateCreated,
                User = ApplicationRepository.GetUserName(t.UserID)
            }
                           );

            Clients.All.loadTopics(jsonRes);
        }
Exemplo n.º 6
0
        public void GetComments(int id)
        {
            var topic   = TopicsRepository.GetTopicByID(id);
            var jsonRes = (from c in topic.Comments
                           select new
            {
                Id = c.CommentID,
                Answer = c.Answer,
                User = ApplicationRepository.GetUserName(c.UserID),
                DatePosted = c.DateCreated
            }


                           );

            Clients.All.loadComments(jsonRes);
        }
Exemplo n.º 7
0
        public ActionResult TopicThreads(Nullable<int> id)
        {
            IEnumerable<Thread> threads = default(IEnumerable<Thread>);

            if (id.HasValue)
            {
                using (var repo = new TopicsRepository())
                {
                    var topic = repo.GetById(id.Value);
                    threads = topic.Threads;
                }
            }

            return View(threads);
        }
Exemplo n.º 8
0
        public void SetUp()
        {
            var connectionString = @"Data Source=ASHTON\ASHTON;Initial Catalog=LessonMonitorTestDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";

            _repository = new TopicsRepository(connectionString);
        }
 public TopicsSearchProvider(ILogger <TopicsSearchProvider> logger,
                             TopicsRepository topicsRepository, ISearcher searcher = null) : base(
         logger, searcher)
 {
     _topicsRepository = topicsRepository;
 }
Exemplo n.º 10
0
 public TopicsController(MasterDBContext db)
 {
     this._db = db;
     this._topicsRepository = new TopicsRepository(db);
 }
Exemplo n.º 11
0
        public ActionResult Details(int id)
        {
            var topic = TopicsRepository.GetTopicByID(id);

            return(View(topic));
        }
Exemplo n.º 12
0
        // GET: Topics
        public ActionResult Index()
        {
            var topics = TopicsRepository.GetTopics();

            return(View(topics));
        }