public JsonResult SaveFiles(string[] description, HttpPostedFileBase files, string Tier)
        {
            int    count = 0;
            string Message, fileName, actualFileName;

            Message = fileName = actualFileName = string.Empty;
            bool           flag       = false;
            int            TierCount  = 0;
            Int64          CustomerID = 0;
            List <dynamic> objDynamic = new List <dynamic>();
            string         strpath    = System.Configuration.ConfigurationManager.AppSettings["UploadImagePath"];

            if (description.Length != 0)
            {
                TierCount  = int.Parse(description[0].Split(',')[0].ToString());
                CustomerID = Int64.Parse(description[0].Split(',')[1].ToString());
            }

            if (Request.Files != null)
            {
                var file = Request.Files[0];
                actualFileName = file.FileName;
                fileName       = Guid.NewGuid() + Path.GetExtension(file.FileName);
                int size = file.ContentLength;
                try
                {
                    file.SaveAs(Path.Combine(Server.MapPath(strpath), fileName));
                    MyProject.Controllers.ViewRequestController.UploadedFile f = new MyProject.Controllers.ViewRequestController.UploadedFile
                    {
                        FileName = actualFileName,
                        FilePath = fileName,
                    };

                    //Save Code Here.
                    string path = Path.Combine(Server.MapPath(strpath), fileName);
                    objDynamic = objData.InsertExcelRecords(path, TierCount, CustomerID, 1);
                    flag       = true;
                }
                catch (Exception ex)
                {
                    Message = "File Upload Failed!";
                }
            }

            return(new JsonResult {
                Data = objDynamic
            });
        }
        public JsonResult SaveFiles(string[] description, HttpPostedFileBase files, AddProductDTO addProductDTO)
        {
            #region comment
            string           Message, fileName, actualFileName;
            string           Manufacturer = string.Empty, Model = string.Empty, PartNo = string.Empty, ProductType = string.Empty, Spec = string.Empty, ProductID = string.Empty;
            ProductMasterDTO productMasterDTO = new ProductMasterDTO();
            Message = fileName = actualFileName = string.Empty;
            bool   flag    = false;
            string strpath = System.Configuration.ConfigurationManager.AppSettings["UploadImagePath"];
            int    size    = 0;
            if (Request.Files != null)
            {
                var list = new List <KeyValuePair <string, string> >();

                foreach (string key in System.Web.HttpContext.Current.Request.Form.AllKeys)
                {
                    string value = System.Web.HttpContext.Current.Request.Form[key];

                    list.Add(new KeyValuePair <string, string>(key, value));
                }
                if (Request.Files.Count != 0)
                {
                    var file = Request.Files[0];
                    actualFileName = file.FileName;
                    fileName       = Guid.NewGuid() + Path.GetExtension(file.FileName);
                    size           = file.ContentLength;
                    file.SaveAs(Path.Combine(Server.MapPath(strpath), fileName));
                    MyProject.Controllers.ViewRequestController.UploadedFile f = new MyProject.Controllers.ViewRequestController.UploadedFile
                    {
                        FileName = actualFileName,
                        FilePath = fileName,
                    };
                }

                var custData = new List <CustomerInfo>();
                try
                {
                    if (list.Count > 0 && list != null)
                    {
                        Manufacturer = list.Find(x => x.Key == "Manufacturer").Value.ToString();
                        Model        = list.Find(x => x.Key == "Model").Value.ToString();
                        PartNo       = list.Find(x => x.Key == "PartNo").Value.ToString();
                        ProductType  = list.Find(x => x.Key == "ProductType").Value.ToString();
                        Spec         = list.Find(x => x.Key == "Spec").Value.ToString();
                        ProductID    = list.Find(x => x.Key == "ProductID").Value.ToString();
                        custData     = JsonConvert.DeserializeObject <List <CustomerInfo> >(list.Find(x => x.Key == "custlist").Value.ToString());
                        // var custData1 = list.Find(x => x.Key == "custlist").Value.ToString();
                    }
                    flag = true;

                    if (!string.IsNullOrEmpty(Manufacturer) && Manufacturer != "undefined")
                    {
                        productMasterDTO.ManufacturerId = Convert.ToInt64(Manufacturer);
                    }
                    if (!string.IsNullOrEmpty(ProductType) && ProductType != "undefined")
                    {
                        productMasterDTO.ProductTypeId = Convert.ToInt64(ProductType);
                    }
                    productMasterDTO.IsActive     = true;
                    productMasterDTO.Model        = Model;
                    productMasterDTO.PartNo       = PartNo;
                    productMasterDTO.Spec         = Spec;
                    productMasterDTO.ImageID      = actualFileName;
                    productMasterDTO.ImagePath    = fileName;
                    productMasterDTO.ImageType    = fileName;// Change name
                    productMasterDTO.ImageLength  = size.ToString();
                    productMasterDTO.strProductId = ProductID;
                    var Data = objData.AddUpdateProducts(custData, productMasterDTO);
                    return(new JsonResult {
                        Data = Data
                    });
                }
                catch (Exception ex)
                {
                    Message = "File Upload Failed!";
                    return(new JsonResult {
                        Data = null
                    });
                }
            }

            #endregion

            return(new JsonResult {
                Data = null
            });
        }