Exemple #1
0
        public async Task <IActionResult> ThatsSpicy([FromForm] string id)
        {
            //get the Umbraco section from appsettings
            var umbracoConfig = this._configuration.GetSection("Umbraco");

            //get the project alias from the section config obtained above
            var projectAlias = umbracoConfig.GetValue <string>("ProjectAlias");

            //get the api key from the section config obtained above
            var apiKey = umbracoConfig.GetValue <string>("APIKey");

            //get an instance of the Content Management API
            var contentManagementService = new ContentManagementService(projectAlias, apiKey);

            //get the content item which I am liking
            var contentItem = await contentManagementService.Content.GetById(Guid.Parse(id));

            int spicyCounter        = contentItem.Properties["spicyCounter"]["$invariant"] == string.Empty ? 0 : Convert.ToInt32(contentItem.Properties["spicyCounter"]["$invariant"]);
            int spicyCounterUpdated = spicyCounter + 1;

            contentItem.SetValue("spicyCounter", spicyCounterUpdated);
            var updateItem = await contentManagementService.Content.Update(contentItem);

            var publishedItem = await contentManagementService.Content.Publish(Guid.Parse(id));

            return(this.Json(new { message = "This is a JSON result.", date = DateTime.Now, spiceFactor = spicyCounterUpdated }));
        }
 public virtual Task<IAppContentManagement> Create()
 {
     var crmService = StartupHelper.CreateCrmService();
         IContentManagementRepository contentmanagementrepository = new ContentManagementRepository();
     IConfigRepository configtrepository = new ConfigRepository();
     IContentManagementService contentmanagementservice = new ContentManagementService(crmService, contentmanagementrepository, configtrepository);
         IAppContentManagement app = new AppContentManagement(contentmanagementservice); 
         return Task.FromResult(app);;
 }
Exemple #3
0
 public ContentManagementController(ContentManagementService ContentManagementService, GalleryService GalleryService, IHostingEnvironment hostingEnvironment)
 {
     _GalleryService = GalleryService;
     _ContentManagementRepository = ContentManagementService;
     _hostingEnvironment          = hostingEnvironment;
 }
Exemple #4
0
 public Ticket(ContentManagementService ContentManagementRepository)
 {
     _ContentManagementRepository = ContentManagementRepository;
 }
Exemple #5
0
 public Season(ContentManagementService ContentManagementRepository)
 {
     _ContentManagementRepository = ContentManagementRepository;
 }
Exemple #6
0
 public News(ContentManagementService ContentManagementRepository)
 {
     _ContentManagementRepository = ContentManagementRepository;
 }
Exemple #7
0
 public HomeController(MenuService MenuRepository, ContentManagementService contentManagementService, GalleryService GalleryService)
 {
     _contentManagementService = contentManagementService;
     _MenuRepository           = MenuRepository;
     _GalleryService           = GalleryService;
 }
 public SpecialEvent(ContentManagementService ContentManagementRepository)
 {
     _ContentManagementRepository = ContentManagementRepository;
 }
Exemple #9
0
        public static async Task UploadImageToMedia(ContentDeliveryService service, string projectAlias)
        {
            System.Console.WriteLine(" ");
            System.Console.WriteLine("In order to upload an image you need to authenticate against the Umbraco Headless Backoffice");

            System.Console.WriteLine("Enter your username:"******"Enter your password:"******" ");
            System.Console.WriteLine("Enter path to an image (png, jpg)");
            var imagePath = System.Console.ReadLine();

            System.Console.WriteLine("Enter a name for the Media item to create");
            var mediaName = System.Console.ReadLine();

            if (File.Exists(imagePath) && !string.IsNullOrEmpty(mediaName))
            {
                var fileName  = Path.GetFileName(imagePath);
                var extension = Path.GetExtension(imagePath).Trim('.');
                System.Console.WriteLine(" ");
                System.Console.WriteLine("Uploading '{0}' to a new Console folder in the Media Library", fileName);

                var rootMediaItems = await service.Media.GetRoot();

                var  folder = rootMediaItems.FirstOrDefault(x => x.Name.Equals("Console"));
                Guid folderId;
                if (folder == null)
                {
                    var createdFolder = await managementService.Media.Create(new Net.Management.Models.Media {
                        MediaTypeAlias = "Folder", Name = "Console"
                    });

                    folderId = createdFolder.Id;
                }
                else
                {
                    folderId = folder.Id;
                }

                var media = new Net.Management.Models.Media {
                    Name = mediaName, MediaTypeAlias = "Image", ParentId = folderId
                };
                media.SetValue("umbracoFile", new { src = fileName }, new FileInfoPart(new FileInfo(imagePath), fileName, $"image/{extension}"));
                var image = await managementService.Media.Create(media);

                var newlyCreatedImage = await service.Media.GetById(image.Id);

                RenderMediaWithUrl(newlyCreatedImage);
            }
            else
            {
                System.Console.WriteLine(" ");
                System.Console.WriteLine("Path to image not found '{0}'", imagePath);
            }

            System.Console.WriteLine(" ");
        }
Exemple #10
0
 public ContentManagementController(ContentManagementService contentManagementService, UserManagementService userManagementService)
 {
     _contentManagementService = contentManagementService;
     _userManagementService    = userManagementService;
 }
Exemple #11
0
 public Slider(ContentManagementService ContentManagementRepository)
 {
     _ContentManagementRepository = ContentManagementRepository;
 }
Exemple #12
0
 public MostVist(ContentManagementService ContentManagementRepository)
 {
     _ContentManagementRepository = ContentManagementRepository;
 }