Beispiel #1
0
        // GET api/Title/5
        public List <Models.Topic> Get(int CategoryId)
        {
            var topics = new List <Models.Topic>();

            using (var context = new FORUMEntities3())
            {
                if (context.Topics.Count() > 0)
                {
                    var xx = (from em in context.Topics
                              where em.CategoryId == CategoryId
                              select new { em.TopicId, em.Title, em.Description, em.Comments, em.Created }).ToList();
                    foreach (var Topic in xx)
                    {
                        var topic = new Models.Topic();
                        topic.CategoryId   = CategoryId;
                        topic.TopicId      = Topic.TopicId;
                        topic.TitleName    = Topic.Title;
                        topic.Description  = Topic.Description;
                        topic.CommentCount = Topic.Comments.Count();
                        topic.CreatedDate  = Topic.Created;
                        topics.Add(topic);
                    }
                }
            }
            return(topics);
        }
        protected override async Task OnParametersSetAsync()
        {
            var topicNode = await NodeService.GetAsync(Id);

            Topic = Models.Topic.Create(topicNode);
            var forumNode = await NodeService.GetAsync(Topic.ForumId);

            Forum = Models.Forum.Create(forumNode);
        }
Beispiel #3
0
 public string Put(Models.Topic topic)
 {
     using (FORUMEntities3 context = new FORUMEntities3())
     {
         var _topic = context.Topics.Single(t => t.TopicId == topic.TopicId);
         _topic.Title       = topic.TitleName;
         _topic.Description = topic.Description;
         _topic.CategoryId  = topic.CategoryId;
         context.SaveChanges();
     }
     return("Title updated successfully");
 }
Beispiel #4
0
 public string Post(Models.Topic topic)
 {
     using (FORUMEntities3 context = new FORUMEntities3())
     {
         var _topic = new AngularWebApi.Topic();
         _topic.CategoryId  = topic.CategoryId;
         _topic.Title       = topic.TitleName;
         _topic.Description = topic.Description;
         _topic.Created     = DateTime.Now;
         context.Topics.Add(_topic);
         context.SaveChanges();
     }
     return("Title added successfully");
 }
Beispiel #5
0
        public Models.Topic GetTopic(int TitleId)
        {
            var topics = new Models.Topic();

            using (var context = new FORUMEntities3())
            {
                if (context.Topics.Count() > 0)
                {
                    var xx = (from em in context.Topics
                              where em.TopicId == TitleId
                              select new { em.TopicId, em.Title, em.Description, em.Comments, em.CategoryId }).ToList();
                    foreach (var Topic in xx)
                    {
                        topics.CategoryId  = Topic.CategoryId;
                        topics.TopicId     = Topic.TopicId;
                        topics.TitleName   = Topic.Title;
                        topics.Description = Topic.Description;
                    }
                }
            }
            return(topics);
        }
 public void Update(UpdateTopicInput input)
 {
     Models.Topic output = Mapper.Map <UpdateTopicInput, Models.Topic>(input);
     _topicManager.Update(output);
 }
 public async Task Create(CreateTopicInput input)
 {
     Models.Topic output = Mapper.Map <CreateTopicInput, Models.Topic>(input);
     await _topicManager.Create(output);
 }