public ActionResult Import(PoleInfoViewModel PoleInfo,HttpPostedFileBase file)
        {
            try
            {
                //return RedirectToAction("Index");
                // TODO: Add insert logic here
                //ViewBag.TaskAssainUser = new SelectList(new UserInformationController().GetDropdownData(), "ID", "UserFullName");
                DataSet ds = new DataSet();
                if (Request.Files["file"].ContentLength > 0)
                {

                    string fileExtension =System.IO.Path.GetExtension(Request.Files["file"].FileName);

                    if (fileExtension == ".xls" || fileExtension == ".xlsx")
                    {

                        string fileLocation = Server.MapPath("~/Content/") + Request.Files["file"].FileName;

                        if (System.IO.File.Exists(fileLocation))
                        {

                            System.IO.File.Delete(fileLocation);
                        }

                        Request.Files["file"].SaveAs(fileLocation);

                        //string _UserID = User.Identity.GetUserId();
                        userInfo = new UserInformationController().GetUserByAspNetUserId(User.Identity.GetUserId());

                        DataTable tbl1 = SQLHelper.GetExcelData(fileLocation, "PoleData");
                        var drs = tbl1.Select("isnull(PoleID,'')=''");

                        foreach (DataRow row in drs)
                        {
                            tbl1.Rows.Remove(row);
                        }

                        foreach (DataRow dr in tbl1.Rows)
                        {

                            PoleInfo obj = new PoleInfo();
                            obj.PoleID = dr["PoleID"].ToString();
                            obj.TypeID = GetPolTypeID(dr["PoleType"].ToString());

                            DateTime _outdatetime;
                            DateTime? TaskAddeddate = null;
                            if (DateTime.TryParse(dr["TaskAddeddate"].ToString(), out _outdatetime))
                            {
                                TaskAddeddate = Convert.ToDateTime(dr["TaskAddeddate"].ToString());
                            }

                            DateTime? TaskPerformeddate = null;
                            if (DateTime.TryParse(dr["TaskPerformeddate"].ToString(), out _outdatetime))
                            {
                                TaskPerformeddate = Convert.ToDateTime(dr["TaskPerformeddate"].ToString());
                            }

                            obj.TaskAddeddate = TaskAddeddate;
                            obj.TaskPerformeddate = TaskPerformeddate;

                            obj.ImageMapPath = dr["ImageMapPath"].ToString();

                            double _outval;
                            double AdjacentPoleHeight = (double.TryParse(dr["AdjacentPoleHeight"].ToString(), out _outval) == false ? default(double) : Convert.ToDouble(dr["AdjacentPoleHeight"].ToString()));

                            obj.AdjacentPoleHeight = AdjacentPoleHeight;
                            obj.TransFormerLoading = dr["TransFormerLoading"].ToString();
                            obj.Notes = dr["Notes"].ToString();
                            obj.ImagesTakenpath = dr["ImagesTakenpath"].ToString();
                            obj.TaskAssainUserID = PoleInfo.TaskAssainUserID;
                            obj.UserID = userInfo.Id;
                            obj.IsActive = true;

                            try
                            {
                                int Id = Save(obj);
                            }
                            catch (Exception ex)
                            {
                                string errormsg = ex.Message;
                            }
                        }

                    }

                }

                return RedirectToAction("Index");
            }
            catch(Exception ex)
            {
                string dd = ex.Message;
                return View(ex.Message);
            }
        }
        public ActionResult Create(PoleInfoViewModel PoleInfo, HttpPostedFileBase file)
        {
            string ImageMapPath = "";
            string ImagesTakenpath = "";
            try
            {
                // TODO: Add insert logic here

                PoleInfo obj = new PoleInfo();
                obj.PoleID = PoleInfo.PoleID;
                obj.TypeID = PoleInfo.TypeID;
                obj.TaskAddeddate = PoleInfo.TaskAddeddate;
                obj.TaskPerformeddate = PoleInfo.TaskPerformeddate;

                obj.AdjacentPoleHeight = PoleInfo.AdjacentPoleHeight;
                obj.TransFormerLoading = PoleInfo.TransFormerLoading;
                obj.Notes = PoleInfo.Notes;

                //obj.UserID = User.Identity.GetUserId();
                //PoleInfoEntities objE = new PoleInfoEntities();
                var FileSavePathList = objE.FileSavePaths.ToList();

                if (Request.Files["ImageMapPathfile"].ContentLength > 0)
                {
                    var _file = Request.Files["ImageMapPathfile"];
                    string _savepath = FileSavePathList.SingleOrDefault(p => p.FileFor == "PoleImageMapPath").FilePath;
                    string fileExtension = System.IO.Path.GetExtension(_file.FileName);
                    ImageMapPath = _savepath + PoleInfo.PoleID.ToString().Trim() + "_MapImage" + fileExtension;

                    if (!System.IO.Directory.Exists(_savepath))
                    {
                        System.IO.Directory.CreateDirectory(_savepath);
                    }
                    _file.SaveAs(ImageMapPath);
                }

                if (Request.Files["ImagesTakenpathfile"].ContentLength > 0)
                {
                    var _file = Request.Files["ImagesTakenpathfile"];
                    string _savepath = FileSavePathList.SingleOrDefault(p => p.FileFor == "PoleImagesTakenpath").FilePath;
                    string fileExtension = System.IO.Path.GetExtension(_file.FileName);
                    ImagesTakenpath = _savepath + PoleInfo.PoleID.ToString().Trim() + "_TakenImages" + fileExtension;
                    if (!System.IO.Directory.Exists(_savepath))
                    {
                        System.IO.Directory.CreateDirectory(_savepath);
                    }
                    _file.SaveAs(ImagesTakenpath);
                }
                obj.ImageMapPath = ImageMapPath;
                obj.ImagesTakenpath = ImagesTakenpath;
                obj.TaskAssainUserID = PoleInfo.TaskAssainUserID;
                var userbasic = new UserInformationController().GetUserByAspNetUserId(User.Identity.GetUserId());
                obj.UserID = userbasic.Id;

                obj.IsActive = true;
                obj.CreateDate = DateTime.Now;

                int Id = Save(obj);

                return RedirectToAction("Index");
            }
            catch
            {
                DeleteFile(ImageMapPath);
                DeleteFile(ImagesTakenpath);
                return View();
            }
        }
        public ActionResult Edit(int id, PoleInfoViewModel PoleInfo)
        {
            try
            {
                // TODO: Add update logic here

                PoleInfo obj = new PoleInfo();
                obj.PoleID = PoleInfo.PoleID;
                obj.TypeID = PoleInfo.TypeID;
                obj.TaskAddeddate = PoleInfo.TaskAddeddate;
                obj.TaskPerformeddate = PoleInfo.TaskPerformeddate;
                obj.ImageMapPath = PoleInfo.ImageMapPath;
                obj.AdjacentPoleHeight = PoleInfo.AdjacentPoleHeight;
                obj.TransFormerLoading = PoleInfo.TransFormerLoading;
                obj.Notes = PoleInfo.Notes;
                obj.ImagesTakenpath = PoleInfo.ImagesTakenpath;
                obj.TaskAssainUserID = PoleInfo.TaskAssainUserID;
                obj.UpdateDate = DateTime.Now;

                //obj.UserID = User.Identity.GetUserId();
                //PoleInfoEntities objE = new PoleInfoEntities();
                var FileSavePathList = objE.FileSavePaths.ToList();

                if (Request.Files["ImageMapPathfile"].ContentLength > 0)
                {
                    var _file = Request.Files["ImageMapPathfile"];
                    string _savepath = FileSavePathList.SingleOrDefault(p => p.FileFor == "PoleImageMapPath").FilePath;
                    string fileExtension = System.IO.Path.GetExtension(_file.FileName);
                    string ImageMapPath = _savepath + PoleInfo.PoleID.ToString().Trim() + "_MapImage" + fileExtension;
                    _file.SaveAs(ImageMapPath);
                    obj.ImageMapPath = ImageMapPath;
                }

                if (Request.Files["ImagesTakenpathfile"].ContentLength > 0)
                {
                    var _file = Request.Files["ImagesTakenpathfile"];
                    string _savepath = FileSavePathList.SingleOrDefault(p => p.FileFor == "PoleImagesTakenpath").FilePath;
                    string fileExtension = System.IO.Path.GetExtension(_file.FileName);
                    string ImagesTakenpath = _savepath + PoleInfo.PoleID.ToString().Trim() + "_TakenImages" + fileExtension;
                    _file.SaveAs(ImagesTakenpath);
                    obj.ImagesTakenpath = ImagesTakenpath;
                }

                int Id = Save(obj);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }