Ejemplo n.º 1
0
        private static String getProductJsonIncludePage(DataTable dt,int index)
        {
            if (dt != null)
            {
                List<ProductModel> details = new List<ProductModel>();
                foreach (DataRow dtrow in dt.Rows)
                {
                    ProductModel obj = new ProductModel();
                    obj.PrdRedirectUrl = dtrow["prdRedirectUrl"].ToString();
                    obj.Name = dtrow["name"].ToString();
                    obj.PrdUrl = dtrow["prdUrl"].ToString();
                    obj.Img = dtrow["imageUrl"].ToString();
                    obj.SeoUrl = dtrow["seourl"].ToString();
                    obj.SubCatId = dtrow["subCatid"].ToString();
                    obj.Storeid = dtrow["storeid"].ToString();
                    obj.RegularPrice = dtrow["regularprice"].ToString();
                    obj.OfferPrice = dtrow["offerprice"].ToString();
                    obj.UniqueId = dtrow["uniqueId"].ToString();
                    obj.PrdId = dtrow["prdid"].ToString();
                    obj.pageSize = AppConstants.PRODUCT_PAGE_SIZE.ToString();
                    obj.pageNext = (index + AppConstants.PRODUCT_PAGE_SIZE + 1).ToString();
                    details.Add(obj);
                }

                JavaScriptSerializer ser = new JavaScriptSerializer();
                return ser.Serialize(details);
            }
            else
            {
                return "No Product Found";
            }
        }
Ejemplo n.º 2
0
        public void updateProducts(MyCategory category)
        {
            FlipkartProductModel exm = JsonConvert.DeserializeObject<FlipkartProductModel>(HttpGet(category.availableVariants.version.get));
            ProductModel prdModel = new ProductModel();
            ProductDAL dal = new ProductDAL();
            while (exm.nextUrl != null)
            {
                foreach (ProductInfoList item in exm.productInfoList)
                {
                    ProductAttributes att = new ProductAttributes();
                    ProductIdentifier idt = new ProductIdentifier();
                    att = item.productBaseInfo.productAttributes;
                    idt = item.productBaseInfo.productIdentifier;

                    prdModel.UniqueId = Guid.NewGuid().ToString().Substring(0, 8);
                    prdModel.PrdId = idt.productId;
                    prdModel.Name = att.title;
                    if (att.productDescription == null)
                    {
                        att.productDescription = FlipkartConstants.INVALID_DESCRIPTION;
                    }
                    prdModel.Description = att.productDescription;
                    prdModel.PrdUrl = att.productUrl;
                    prdModel.PrdRedirectUrl = att.productUrl;
                    if (att.imageUrls._275x275 == null)
                    {
                        att.imageUrls._275x275 = FlipkartConstants.DEFAULT_IMAGE;
                    }
                    prdModel.Img = att.imageUrls._275x275;
                    prdModel.Width = FlipkartConstants.DEFAULT_IMAGE_WIDTH_AND_HEIGHT_275PX;
                    prdModel.Height = FlipkartConstants.DEFAULT_IMAGE_WIDTH_AND_HEIGHT_275PX;
                    prdModel.Storeid = FlipkartConstants.FLIPKART_STORE_ID_FOKATDEALS;
                    prdModel.RegularPrice = att.maximumRetailPrice.amount + " Rs.";
                    prdModel.OfferPrice = att.sellingPrice.amount + " Rs.";
                    prdModel.SubCatId = category.apiName;
                    prdModel.CreatedOn = System.DateTime.Now + "";
                    prdModel.ExpireOn = "";
                    String status = "";
                    if (att.inStock)
                    {
                        status = "A";
                    }
                    else
                    {
                        status = "D";
                    }
                    prdModel.Status = status;
                    prdModel.Custom1 = att.productBrand;
                    prdModel.Custom2 = att.codAvailable + "";

                    int i = dal.InsertProducts(prdModel);
                }

                exm = JsonConvert.DeserializeObject<FlipkartProductModel>(HttpGet(exm.nextUrl));

            }
        }
Ejemplo n.º 3
0
        public int InsertProducts(ProductModel prdModel)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("usp_InsertProduct", con);
                cmd.Parameters.AddWithValue("@uniquId", prdModel.UniqueId);
                cmd.Parameters.AddWithValue("@prdid", prdModel.PrdId);
                cmd.Parameters.AddWithValue("@name", prdModel.Name);
                cmd.Parameters.AddWithValue("@desc", prdModel.Description);
                cmd.Parameters.AddWithValue("@prdUrl", prdModel.PrdUrl);
                cmd.Parameters.AddWithValue("@prdre", prdModel.PrdRedirectUrl);
                cmd.Parameters.AddWithValue("@img", prdModel.Img);
                cmd.Parameters.AddWithValue("@w", prdModel.Width);
                cmd.Parameters.AddWithValue("@h", prdModel.Height);
                cmd.Parameters.AddWithValue("@storeid", prdModel.Storeid);
                cmd.Parameters.AddWithValue("@reg", prdModel.RegularPrice);
                cmd.Parameters.AddWithValue("@sell", prdModel.OfferPrice);
                cmd.Parameters.AddWithValue("@catid", prdModel.SubCatId);
                cmd.Parameters.AddWithValue("@status", prdModel.Status);
                cmd.Parameters.AddWithValue("@c1", prdModel.Custom1);
                cmd.Parameters.AddWithValue("@c2", prdModel.Custom2);

                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                int i = cmd.ExecuteNonQuery();
                con.Close();
                return i;
            }
            catch
            {
                return -99;
            }
        }