Exemplo n.º 1
0
        /// <summary>
        /// Updates the given <see cref="Theme"/>.
        /// </summary>
        /// <param name="themeId">Id of the object being updated.</param>
        /// <param name="theme">The <see cref="Theme"/> to update.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        /// <returns>The updated <see cref="Theme"/>.</returns>
        public virtual async Task <Entities.Theme> UpdateAsync(long themeId, Entities.Theme theme, CancellationToken cancellationToken = default)
        {
            var req     = PrepareRequest($"themes/{themeId}.json");
            var content = new JsonContent(new
            {
                theme = theme
            });
            var response = await ExecuteRequestAsync <Entities.Theme>(req, HttpMethod.Put, cancellationToken, content, "theme");

            return(response.Result);
        }
Exemplo n.º 2
0
        public Update(Entities.Theme theme)
        {
            _theme = theme;

            InitializeComponent();

            txbTheme.Text       = _theme.Name;
            txbDescription.Text = _theme.Description;

            _themeService = new ThemeService();
        }
Exemplo n.º 3
0
        private async Task <Entities.Theme> _CreateAsync(Entities.Theme theme, CancellationToken cancellationToken, string sourceUrl = null)
        {
            var req  = PrepareRequest("themes.json");
            var body = theme.ToDictionary();

            if (!string.IsNullOrEmpty(sourceUrl))
            {
                body.Add("src", sourceUrl);
            }

            var content = new JsonContent(new
            {
                theme = body
            });
            var response = await ExecuteRequestAsync <Entities.Theme>(req, HttpMethod.Post, cancellationToken, content, "theme");

            return(response.Result);
        }
Exemplo n.º 4
0
        private static List <Entities.Theme> GetAllThemes(PortalSettings PortalSettings)
        {
            string ThemeValue = "Basic";

            Core.Data.Entities.Setting ThemeSetting = Core.Managers.SettingManager.GetSettings(PortalSettings.PortalId, -1, "setting_theme").Where(s => s.Name == "Theme").FirstOrDefault();
            if (ThemeSetting != null)
            {
                ThemeValue = ThemeSetting.Value;
            }

            string strRoot = HttpContext.Current.Server.MapPath("~/Portals/_default/vThemes/");

            string[] arrThemes           = Directory.GetDirectories(strRoot);
            List <Entities.Theme> Themes = new List <Entities.Theme>();

            foreach (string Theme in arrThemes)
            {
                Entities.Theme th = new Entities.Theme
                {
                    Text  = Theme.Replace(strRoot, ""),
                    Value = Theme.Replace(strRoot, "")
                };
                if (File.Exists(strRoot + th.Value + "\\Theme.jpg"))
                {
                    th.Thumbnail = (HttpContext.Current.Server.MapPath("~/Portals/_default/vThemes/" + th.Value + "/Theme.jpg"));
                }

                if (ThemeValue == th.Value)
                {
                    Themes.Insert(0, th);
                }
                else
                {
                    Themes.Add(th);
                }
            }
            return(Themes);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new theme on the store. The theme always starts out with a role of
 /// "unpublished." If the theme has a different role, it will be assigned that only after all of its
 /// files have been extracted and stored by Shopify (which might take a couple of minutes).
 /// </summary>
 /// <param name="theme">The new theme.</param>
 /// <param name="sourceUrl">A URL that points to the .zip file containing the theme's source files.</param>
 /// <param name="cancellationToken">Cancellation Token</param>
 public virtual async Task <Entities.Theme> CreateAsync(Entities.Theme theme, string sourceUrl, CancellationToken cancellationToken = default)
 {
     return(await _CreateAsync(theme, cancellationToken, sourceUrl));
 }