public ActionResult Create(PoleImage poleimage, FormCollection collection)
        {
            foreach (string fileName in Request.Files)
            {
                HttpPostedFileBase file = Request.Files[fileName];
            }
            //, IEnumerable files
            //var userbasic = new UserInformationController().GetUserByAspNetUserId(User.Identity.GetUserId());
            userInfo = TempData["userInfo"] as UserInformation;
            if (ModelState.IsValid)
            {
                poleimage.UserID = userInfo.Id;
                //db.PoleImages.Add(poleimage);
                //db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.PoleInfoID = new SelectList(GetPoleIDList(), "ID", "PoleID", poleimage.PoleInfoID);
            ViewBag.UserID = new SelectList(db.UserInformations, "Id", "UserFullName", poleimage.UserID);
            return View(poleimage);
        }
        public ActionResult UploadFiles(IEnumerable files, PoleImage poleimage)
        {
            string TempPath = Server.MapPath("~/Content/TempFile/");
            userInfo = new UserInformationController().GetUserByAspNetUserId(User.Identity.GetUserId());
            //List<PoleImage> objlist = new List<PoleImage>();
            foreach (HttpPostedFileBase file in files)
            {
                string filePath = Path.Combine(TempPath, file.FileName);
                //System.IO.File.WriteAllBytes(filePath, ReadData(file.InputStream));

                //PoleImage obj = new PoleImage();
                poleimage.UserID = userInfo.Id;
                //db.PoleImages.Add(poleimage);
                //db.SaveChanges();
            }

            return Json("All files have been successfully stored.");
        }
        public ActionResult SaveUploadedPoleImage(List<PoleImageList> obj)
        {
            try
            {
                if(obj==null)
                {
                    return Json(new { Success = 3, ID = 0, ex = "" });
                }

                string PoleID="";
                PoleInfoEntities objE = new PoleInfoEntities();
                var FileSavePathList = objE.FileSavePaths.ToList();
                string _savepath = FileSavePathList.SingleOrDefault(p => p.FileFor == "PoleImageMapPath").FilePath;
                userInfo = new UserInformationController().GetUserByAspNetUserId(User.Identity.GetUserId());
                foreach (var itm in obj)
                {
                    var id = itm.ID;
                    PoleID = itm.PoleID;
                    var Imgae64 = itm.Image64;

                    Image image = PoleClass.Base64ToImage(Imgae64);

                    string ImageMapPath = _savepath + itm.PoleID.ToString().Trim() + "_MapImage"+itm.ID.ToString() + ".jpg";

                    //string imgname = PoleID+"_img_"+id.ToString()+".jpg";
                    image.Save(ImageMapPath, System.Drawing.Imaging.ImageFormat.Jpeg);

                    PoleImage poleimage = new PoleImage();
                    poleimage.UserID = userInfo.Id;
                    poleimage.PoleInfoID = itm.PoleInfoID;
                    poleimage.ImageMapPath = ImageMapPath;
                    poleimage.CreateDate = DateTime.Now;

                    db.PoleImages.Add(poleimage);
                    db.SaveChanges();

                }
                //var msg = "Saved Successfully Completed";
                //return Content(msg, "text/html");
                return Json(new { Success = 1, ID = PoleID, ex = "" });

            }
            catch (Exception ex)
            {
                return Json(new { Success = 0, ex = ex.Message.ToString() });
                //throw new HttpException(500, ex.Message);
            }

            //return Json(new { Success = 0, ex = new Exception("Unable to save").Message.ToString() });
        }