コード例 #1
0
        public async Task <String> CreateNewStyleDoc(StyleFileData StyleFileData)
        {
            try
            {
                string Fill_path  = "";
                string product_id = StyleFileData.product_id;

                if (StyleFileData != null && StyleFileData.StyleImage != null)
                {
                    Fill_path = StyleFileData.StyleImage.FileName;
                    Fill_path = UploadPath + Fill_path;
                    using (var stream = new FileStream(Fill_path, FileMode.Create))
                    {
                        await StyleFileData.StyleImage.CopyToAsync(stream);
                    }
                    JObject product_doc = new JObject();

                    product_doc.Add("product_vendor_image", StyleFileData.StyleImage.FileName);

                    product_id = await _BadgerApiHelper.GenericPutAsyncString <String>(product_doc.ToString(Formatting.None), "/product/updatespecific/" + product_id);
                }

                return(Fill_path);
            }
            catch (Exception ex)
            {
                return("0");
            }
        }
コード例 #2
0
        public async Task <String> CreateNewVendorLogo(vendorFileData vendorLogo)
        {
            string loginUserId = await _LoginHelper.GetLoginUserId();

            string messageDocuments        = "";
            string messageAlreadyDocuments = "";

            try
            {
                List <IFormFile> files = vendorLogo.vendorDocuments;

                foreach (var formFile in files)
                {
                    if (formFile.Length > 0)
                    {
                        awsS3Helper.UploadToS3(formFile.FileName, formFile.OpenReadStream(), S3bucket, S3folder);
                        int     ref_id          = Int32.Parse(vendorLogo.Vendor_id);
                        JObject vendorDocuments = new JObject();
                        vendorDocuments.Add("vendor_id", ref_id);
                        vendorDocuments.Add("logo", formFile.FileName);
                        await _BadgerApiHelper.GenericPutAsyncString <String>(vendorDocuments.ToString(Formatting.None), "/vendor/updatespecific/" + vendorLogo.Vendor_id);
                    }
                }

                return(messageDocuments + " \r\n " + messageAlreadyDocuments);
            }
            catch (Exception ex)
            {
                return("0");
            }
        }
コード例 #3
0
        public async Task <string> UpdatePhotoshootProductStatus(string product_id, string status)
        {
            string user_id = await _ILoginHelper.GetLoginUserId();

            JObject photoshoot = new JObject();

            photoshoot.Add("product_shoot_status_id", status);
            photoshoot.Add("updated_by", user_id);
            photoshoot.Add("updated_at", _common.GetTimeStemp());

            string returnStatus = await _BadgerApiHelper.GenericPutAsyncString <string>(photoshoot.ToString(Formatting.None), "/Photoshoots/UpdatePhotoshootProductStatus/" + product_id);

            return(returnStatus);
        }
コード例 #4
0
        public async Task <string> UpdateAttributes([FromBody]   JObject json, int productId)
        {
            JArray product_subtype_ids = new JArray();
            string user_id             = await _LoginHelper.GetLoginUserId();

            List <Fabric> _fabrics = new List <Fabric>();
            JObject       product  = new JObject();

            product.Add("size_and_fit_id", json.Value <string>("size_fit"));
            product.Add("product_retail", json.Value <string>("product_retail"));
            product.Add("product_name", json.Value <string>("product_name"));
            product.Add("product_cost", json.Value <string>("product_cost"));
            product.Add("product_discount", json.Value <string>("product_discount"));
            product.Add("product_detail_1", json.Value <string>("product_detail_1"));
            product.Add("product_detail_2", json.Value <string>("product_detail_2"));
            product.Add("product_detail_3", json.Value <string>("product_detail_3"));
            product.Add("product_detail_4", json.Value <string>("product_detail_4"));
            product.Add("is_ready", json.Value <bool>("is_ready"));
            product.Add("pairProductIds", json.Value <string>("pairProductIds"));
            product.Add("RemovePairWithProductIds", json.Value <string>("RemovePairWithProductIds"));
            product.Add("otherColorsProductIds", json.Value <string>("otherColorsProductIds"));
            product.Add("RemoveOtherColorProductIds", json.Value <string>("RemoveOtherColorProductIds"));


            product.Add("photoshootStatus", json.Value <string>("photoshootStatus"));
            product.Add("photoshootStatusOld", json.Value <string>("photoshootStatusOld"));

            product.Add("updated_by", user_id);
            product.Add("updated_at", _common.GetTimeStemp());

            _fabrics = json.Value <JArray>("fabricArray").ToObject <List <Fabric> >();


            string returnStatus = await _BadgerApiHelper.GenericPutAsyncString <string>(product.ToString(Formatting.None), "/Product/UpdateAttributes/" + productId.ToString());

            if (json["product_subtype_ids"] != null)
            {
                product_subtype_ids = (JArray)json["product_subtype_ids"];
            }
            for (int i = 0; i < product_subtype_ids.Count(); i++)
            {
                string category_id = product_subtype_ids[i].Value <string>("category_id");
                string action      = product_subtype_ids[i].Value <string>("action");

                JObject productCategories = new JObject();
                productCategories.Add("product_id", productId);
                productCategories.Add("category_id", category_id);
                productCategories.Add("action", action);
                productCategories.Add("created_by", user_id);
                productCategories.Add("created_at", _common.GetTimeStemp());

                var temp_product_category_id = await _BadgerApiHelper.GenericPostAsyncString <String>(productCategories.ToString(Formatting.None), "/product/UpdateProductCategory");
            }
            string sku         = "";
            string tagAddedIds = json.Value <string>("tagAddedIds");

            if (tagAddedIds != "")
            {
                int countComma = tagAddedIds.Count(c => c == ',');
                if (countComma > 0)
                {
                    var ids = tagAddedIds.Split(",");
                    foreach (var tagId in ids)
                    {
                        JObject product_attr = new JObject();
                        Int16   attribute_id = Int16.Parse(tagId);

                        product_attr.Add("attribute_id", attribute_id);
                        product_attr.Add("product_id", productId);
                        product_attr.Add("value", "");

                        product_attr.Add("created_by", user_id);
                        product_attr.Add("created_at", _common.GetTimeStemp());
                        String attr_value_id = await _BadgerApiHelper.GenericPostAsyncString <String>(product_attr.ToString(Formatting.None), "/attributevalues/create");


                        JObject product_attr_value = new JObject();
                        product_attr_value.Add("product_id", productId);
                        product_attr_value.Add("attribute_id", attribute_id);
                        product_attr_value.Add("value_id", attr_value_id);

                        product_attr_value.Add("created_by", user_id);
                        // product_attr_value.Add("created_at", _common.GetTimeStemp()); need to create in DB
                        String product_attribute_value_id = await _BadgerApiHelper.GenericPostAsyncString <String>(product_attr_value.ToString(Formatting.None), "/product/createAttributesValues");

                        JObject product_attribute_obj = new JObject();
                        product_attribute_obj.Add("product_id", productId);
                        product_attribute_obj.Add("attribute_id", attribute_id);
                        product_attribute_obj.Add("value_id", attr_value_id);
                        product_attribute_obj.Add("sku", sku);

                        product_attribute_obj.Add("created_by", user_id);
                        //product_attribute_obj.Add("created_at", _common.GetTimeStemp()); need to create in DB
                        String product_attribute_id = await _BadgerApiHelper.GenericPostAsyncString <String>(product_attribute_obj.ToString(Formatting.None), "/product/createProductAttribute");
                    }
                }
                else
                {
                }
            }
            if (_fabrics.Count() > 0)
            {
                await _ProductHelper.UpdateFabric(_fabrics, int.Parse(user_id));
            }



            if (json.Value <string>("photoshootStatus") != json.Value <string>("photoshootStatusOld"))
            {
                JObject photoshoot = new JObject();
                photoshoot.Add("product_shoot_status_id", json.Value <string>("photoshootStatus"));
                photoshoot.Add("updated_by", user_id);
                photoshoot.Add("updated_at", _common.GetTimeStemp());
                await _BadgerApiHelper.GenericPutAsyncString <string>(photoshoot.ToString(Formatting.None), "/Photoshoots/UpdatePhotoshootProductStatus/" + productId.ToString());
            }

            if (json.Value <string>("oldInternalNotes") != json.Value <string>("internalNotes"))
            {
                JObject productNote = new JObject();
                productNote.Add("ref_id", productId);
                productNote.Add("note", json.Value <string>("internalNotes"));
                productNote.Add("created_by", Int32.Parse(user_id));

                await _BadgerApiHelper.GenericPostAsyncString <String>(productNote.ToString(Formatting.None), "/product/notecreate");
            }
            return("success");
        }