public async Task <ActionResult> CustomFieldUpdate(int?id)
        {
            MetaField field;

            if (id.HasValue)
            {
                var fieldQuery = await _customFieldService.Query(x => x.ID == id).Include(x => x.MetaCategories).SelectAsync();

                field = fieldQuery.FirstOrDefault();
            }
            else
            {
                field = new MetaField()
                {
                    Required   = false,
                    Searchable = false
                }
            };

            var categories = await _categoryService.Query().SelectAsync();

            var model = new MetaFieldModel()
            {
                MetaField  = field,
                Categories = categories.ToList()
            };

            return(View(model));
        }
        public async Task <ActionResult> OnPostUpdate(long productId, MetaFieldModel metaField)
        {
            ModelState.Clear();
            if (ModelState.IsValid)
            {
                var metafieldService = _shopifyFactory.CreateMetaFieldService();
                var field            = await metafieldService.UpdateAsync(metaField.Id, new MetaField()
                {
                    Namespace = metaField.Namespace,
                    Key       = metaField.Key,
                    Value     = metaField.Value
                });

                return(RedirectToPage("Metafields", new { productId }));
            }
            return(await OnGet(productId));
        }
        public async Task <ActionResult> OnGet(long productId)
        {
            var productService   = _shopifyFactory.CreateProductService();
            var metafieldService = _shopifyFactory.CreateMetaFieldService();
            var product          = await productService.GetAsync(productId, "title,id");

            Product    = product;
            MetaFields = await metafieldService.ListAsync(productId, "products", new MetaFieldFilter()
            {
                Namespace = "rls"
            });

            if (CreateModel == null)
            {
                CreateModel = new MetaFieldModel
                {
                    Key       = "subtitle",
                    Namespace = "rls"
                };
            }

            return(Page());
        }