Example #1
0
        public async Task <IActionResult> GetCommentView(long commentId)
        {
            CommentModule invMod = new CommentModule();

            CommentView view = await invMod.Comment.Query().GetViewById(commentId);

            return(Ok(view));
        }
Example #2
0
        public async Task <IActionResult> DeleteComment([FromBody] CommentView view)
        {
            CommentModule invMod  = new CommentModule();
            Comment       comment = await invMod.Comment.Query().MapToEntity(view);

            invMod.Comment.DeleteComment(comment).Apply();

            return(Ok(view));
        }
Example #3
0
        public async Task <IActionResult> UpdateComment([FromBody] CommentView view)
        {
            CommentModule invMod = new CommentModule();

            Comment comment = await invMod.Comment.Query().MapToEntity(view);


            invMod.Comment.UpdateComment(comment).Apply();

            CommentView retView = await invMod.Comment.Query().GetViewById(comment.CommentId);


            return(Ok(retView));
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            NinjectModule studentModule = new StudentModule();
            NinjectModule postModule    = new PostModule();
            NinjectModule serviceModule = new ServiceModule();
            NinjectModule tagModule     = new TagModule();
            NinjectModule commentModule = new CommentModule();
            NinjectModule autoMapper    = new AutoMapperModule();
            var           kernel        = new StandardKernel(studentModule, postModule, serviceModule, tagModule, commentModule, autoMapper);

            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
        }
Example #5
0
        public async Task <IActionResult> AddComment([FromBody] CommentView view)
        {
            CommentModule invMod = new CommentModule();

            NextNumber nnComment = await invMod.Comment.Query().GetNextNumber();

            view.CommentNumber = nnComment.NextNumberValue;

            Comment comment = await invMod.Comment.Query().MapToEntity(view);

            invMod.Comment.AddComment(comment).Apply();

            CommentView newView = await invMod.Comment.Query().GetViewByNumber(view.CommentNumber);


            return(Ok(newView));
        }
        public void ShouldRegisterCommentTimelineBarElementToTimelineBarRegistry()
        {
            var timelineBarRegistry = new MockTimelineBarRegistry();
            var regionManager = new MockRegionManager();
            regionManager.Regions.Add("ToolsRegion", new MockRegion());
            var container = new MockUnityResolver();

            container.Bag.Add(typeof(ICommentViewPresentationModel), new MockCommentViewPresentationModel());
            container.Bag.Add(typeof(ITimelineBarRegistry), timelineBarRegistry);

            var module = new CommentModule(container, regionManager);

            Assert.IsFalse(timelineBarRegistry.RegisterTimelineBarElementCalled);

            module.Initialize();

            Assert.IsTrue(timelineBarRegistry.RegisterTimelineBarElementCalled);
            Assert.AreEqual("Comment", timelineBarRegistry.RegisterTimelineBarElementKeyArgument);
            Assert.IsNotNull(timelineBarRegistry.RegisterTimelineBarElementValueArgument);
        }
        public void ShouldAddCommentViewToToolsRegion()
        {
            var toolsRegion = new MockRegion();
            var regionManager = new MockRegionManager();
            var container = new MockUnityResolver();

            container.Bag.Add(typeof(ICommentViewPresentationModel), new MockCommentViewPresentationModel());
            container.Bag.Add(typeof(ITimelineBarRegistry), new MockTimelineBarRegistry());

            regionManager.Regions.Add("ToolsRegion", toolsRegion);

            var module = new CommentModule(container, regionManager);

            Assert.AreEqual(0, toolsRegion.AddedViews.Count);

            module.Initialize();

            Assert.AreEqual(1, toolsRegion.AddedViews.Count);
            Assert.IsInstanceOfType(toolsRegion.AddedViews[0], typeof(ICommentView));
        }