protected override ActionResult <ContentActionOutput> ActionImplemetation()
        {
            IContentDispatcher cd      = this.getGlobalObject <IContentDispatcher>();
            IContent           content = cd.GetContent(input.getContenTypeName(), input.guid);

            if (content == null)
            {
                return(ActionResultTemplates <ContentActionOutput> .InvalidInput);
            }

            var result = new ContentActionOutput();

            if (user.isFavorite(content))
            {
                return(result);
            }

            var cc       = this.getGlobalObject <IGlobalContentCreator>();
            var favorite = cc.getAndAddNewContent <UserFavorite>();

            favorite.user = user;
            favorite.content_reference = new ContentReference(content);
            result.new_contents.Add(favorite);
            //we add also the content so the ui will reload it with the new actions
            result.changed_contents.Add(content);

            return(result);
        }
Exemple #2
0
            protected override ActionResult <ContentType> ActionImplemetation()
            {
                IContentDispatcher cd = this.getGlobalObject <IContentDispatcher>();

                cd.Add(this.input);
                return(new ActionResult <ContentType>(this.input));
            }
        protected override ActionResult <ContentActionOutput> ActionImplemetation()
        {
            IContentDispatcher cd      = this.getGlobalObject <IContentDispatcher>();
            IContent           content = cd.GetContent(input.getContenTypeName(), input.guid);

            if (content == null)
            {
                return(ActionResultTemplates <ContentActionOutput> .InvalidInput);
            }

            var result = new ContentActionOutput();

            if (!user.isFavorite(content))
            {
                return(result);
            }

            var favorites = cd.GetAllByFilter <UserFavorite>(x => x.user.guid == user.guid && x.content_reference.guid == content.guid);

            cd.RemoveContents(favorites);
            result.deleted_contents.AddRange(favorites);
            //we add also the content so the ui will reload it with the new actions
            result.changed_contents.Add(content);
            return(result);
        }
Exemple #4
0
        protected override ActionResult <ContentActionOutput> ActionImplemetation()
        {
            IContentDispatcher cd      = this.getGlobalObject <IContentDispatcher>();
            IContent           content = cd.GetContent(input.getContenTypeName(), input.guid);

            if (content == null)
            {
                return new ActionResult <ContentActionOutput>()
                       {
                           isSuccessfull = false, UnAuthorized = false, message = "content not found"
                       }
            }
            ;
            var result = new ContentActionOutput();

            result.deleted_contents.Add(content);
            result.message  = "CONTENT_DELETED";
            result.next_url = new ContentTypeUrl(content.GetType());
            cd.Remove(content);
            //history
            history_message_data = new WhoWhatWhen()
            {
                who  = user.guid,
                what = new ContentReference(content),
                when = DateTime.Now
            };
            history_tags.Add(nameof(ContentDeleteAction));
            history_tags.Add(content.getContenTypeName());
            return(result);
        }
Exemple #5
0
            protected override ActionResult <Guid> ActionImplemetation()
            {
                IGlobalContentCreator cc = this.getGlobalObject <IGlobalContentCreator>();
                IContent           c     = cc.getNewContent <TestContentType>();
                IContentDispatcher cd    = this.getGlobalObject <IContentDispatcher>();

                cd.Add(c);
                return(new ActionResult <Guid>(c.guid));
            }
        protected override bool AuthorizeImplementation()
        {
            IContentDispatcher cd      = this.getGlobalObject <IContentDispatcher>();
            IContent           content = cd.GetContent(input.getContenTypeName(), input.guid);

            if (content == null)
            {
                return(false);
            }
            return(!user.isFavorite(content));
        }
Exemple #7
0
        protected override bool AuthorizeImplementation()
        {
            IContentDispatcher cd      = this.getGlobalObject <IContentDispatcher>();
            IContent           content = cd.GetContent(input.getContenTypeName(), input.guid);

            if (content == null)
            {
                return(false);
            }
            return(content.GetType().getMysteryAttribute <ContentDeleteAttribute>().canDelete(content, user));
        }
        protected override ActionResult <ContentActionOutput> ActionImplemetation()
        {
            IContentDispatcher cd = this.getGlobalObject <IContentDispatcher>();
            var favorites         = from x in  cd.GetAllByFilter <UserFavorite>(x => x.user.guid == user.guid)
                                    where x.content_reference != null
                                    select x.content_reference.getContent();

            var result = new ContentActionOutput();

            result.contents.AddRange(from x in favorites where x != null && x.canAccess(user) select x);
            return(result);
        }
Exemple #9
0
        public void WebContentDispatcherNoExceptionTest()
        {
            IContentDispatcher container = null;
            WebActionExecutor  executor  = null;
            ContentsDatabase   db        = this.getGlobalObject <ContentsDatabase>();
            TestContentType    c         = null;

            ExecuteTest(() => {
                container = WebContentDispatcher.getDispatcher();
                c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                container.Add(c);
                Guid guid = c.guid;
                executor  = WebActionExecutor.current;
                return(guid.Tiny());
            });
            Assert.IsTrue(executor.status == WebActionExecutorStatus.done);
            Assert.IsTrue(db.Contains(c));
        }
Exemple #10
0
        public void CreateAContentEditItandDeleteITInDbTest()
        {
            Guid guid = Guid.Empty;

            using (WebActionExecutor e = new WebActionExecutor())
            {
                string json = e.executeAction(new CreateAContentInDb <TestContentType>()).json_output;
                IMysteryJsonConverter converter = this.getGlobalObject <IMysteryJsonConverter>();
                guid = converter.readJson <Guid>(json);
            }
            using (WebActionExecutor e = new WebActionExecutor())
            {
                IContentDispatcher cd = this.getGlobalObject <IContentDispatcher>();
                TestContentType    c  = cd.GetContent <TestContentType>(guid);
                c.a_string = "Carlo";
                e.executeAction(new SaveAContentInDb <TestContentType>(), c);
            }

            Assert.IsTrue(true);
        }
Exemple #11
0
 public ContentMemory()
 {
     _cache = new ConcurrentDictionary <Guid, IContent>();
     _db    = this.getGlobalObject <ContentsDatabase>();
 }
Exemple #12
0
 public void Dispose()
 {
     _db    = null;
     _cache = null;
 }