Esempio n. 1
0
        public bool CheckEqualProducts(ref JsonProduct product)
        {
            if (id != product.id)
            {
                return(false);
            }

            if (category_id != product.category_id)
            {
                return(false);
            }

            if (title != product.title)
            {
                return(false);
            }

            if (content != product.content)
            {
                return(false);
            }

            if (price != product.price)
            {
                return(false);
            }

            if (old_price != product.old_price)
            {
                return(false);
            }

            if (status != product.status)
            {
                return(false);
            }

            if (keywords != product.keywords)
            {
                return(false);
            }

            if (description != product.description)
            {
                return(false);
            }

            if (img != product.img)
            {
                return(false);
            }

            if (hit != product.hit)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public int EditProduct(ref JsonProduct product)
        {
            var json = JsonSerializer.Serialize(product);
            var data = new StringContent(json, Encoding.UTF8);

            Console.WriteLine(data.ReadAsStringAsync().Result);

            var response = client.PostAsync(BASE_URL + "editproduct", data).Result;

            return(response.StatusCode.GetHashCode());
        }
Esempio n. 3
0
        public ApiCreateResponse CreateProduct(ref JsonProduct product)
        {
            var json = JsonSerializer.Serialize(product);
            var data = new StringContent(json, Encoding.UTF8);

            Console.WriteLine("PRODUCT CREATION " + data.ReadAsStringAsync().Result);

            var response = client.PostAsync(BASE_URL + "addproduct", data).Result;

            ApiCreateResponse createResponse = JsonSerializer.Deserialize <ApiCreateResponse>(response.Content.ReadAsStringAsync().Result);

            createResponse.statusCode = response.StatusCode.GetHashCode();
            return(createResponse);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            JsonProduct json = new JsonProduct();
            string      temp = JsonConvert.SerializeObject(json);

            Console.WriteLine(temp);

            ApiRequest        api            = new ApiRequest();
            ApiCreateResponse createResponse = api.CreateProduct(ref json);

            if (createResponse.statusCode == 200)
            {
                Console.WriteLine("Creation complete");
            }

            Console.WriteLine(createResponse.id);
        }