public async Task <IActionResult> Create([Bind("Id,Name,ShortDescription,LongDescription,CurrentStock,CostPrice,SalePrice,ProductCode,Status,OpeningStock,OpeningDate,ProductFeatures,CreatedBy")] Product product, IList <IFormFile> PImages)
        {
            string AllFileNames = "";

            if (PImages != null && PImages.Count > 0)
            {
                foreach (IFormFile PImage in PImages)
                {
                    string FolderPath = ENV.ContentRootPath + "\\wwwroot\\Images\\ProductImages\\";
                    string FileName   = Guid.NewGuid() + Path.GetExtension(PImage.FileName);
                    PImage.CopyTo(new FileStream(FolderPath + FileName, FileMode.Create));
                    AllFileNames += (FileName + ",");
                }
            }

            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"].ToString();
            }
            if (ModelState.IsValid)
            {
                if (AllFileNames.Contains(','))
                {
                    AllFileNames = AllFileNames.Remove(AllFileNames.LastIndexOf(','));
                }
                product.Images = AllFileNames;
                ORM.Add(product);
                await ORM.SaveChangesAsync();

                TempData["Message"] = product.Name + " Successfully added";
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Picture,Status,ShortDescription,LongDescription,CreateDate,CreatedBy,ModifiedDate,ModifiedBy")] Category category, IFormFile CImage)
        {
            string FileName = "";

            if (CImage != null)
            {
                string FTPFolderPath = ENV.ContentRootPath + "\\wwwroot\\Images\\CategoryImages";

                string FileExt = Path.GetExtension(CImage.FileName);

                FileName = Guid.NewGuid() + FileExt;
                string FinalFilePath = FTPFolderPath + "\\" + FileName;



                FileStream FS = new FileStream(FinalFilePath, FileMode.Create);

                CImage.CopyTo(FS);
            }
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"].ToString();
            }
            if (ModelState.IsValid)
            {
                category.Picture = FileName;
                ORM.Add(category);
                await ORM.SaveChangesAsync();

                TempData["Message"] = category.Name + " Successfully added";
                HttpContext.Session.SetString("CNAME", category.Name);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }