Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
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);
        }