public ActionResult Upload(List <Datasheet> lstDatasheets)
        {
            if (Request != null)
            {
                if (Request.Form["LoadDatasheets"] != null)
                {
                    CCTokenSystemContext dbcontext = new CCTokenSystemContext();
                    HttpPostedFileBase   file      = Request.Files["DataFileupload"];
                    string fileExtension           = System.IO.Path.GetExtension(Request.Files["DataFileupload"].FileName);
                    Session["resourceFile"] = file;
                    if (fileExtension == ".xls" || fileExtension == ".xlsx")
                    {
                        var package = new ExcelPackage(file.InputStream);
                        lstDatasheets = new List <Datasheet>();
                        int id = 0;
                        foreach (ExcelWorksheet ws in package.Workbook.Worksheets)
                        {
                            Datasheet ds = new Datasheet();
                            ds.id   = ++id;
                            ds.Name = ws.Name;
                            lstDatasheets.Add(ds);
                        }
                    }
                    else
                    {
                        ViewData["error"] = "Please, Uplaod Excel file only";
                    }
                    return(View("Index", lstDatasheets));
                }
                if (Request.Form["LoadData"] != null)
                {
                    if (lstDatasheets != null && lstDatasheets.Count >= 1)
                    {
                        HttpPostedFileBase file = (HttpPostedFileBase)Session["resourceFile"];

                        foreach (Datasheet ds in lstDatasheets)
                        {
                            if (ds.Name.Equals("students") && ds.TobeUploaded)
                            {
                                LoadStudent(file);
                            }
                            if (ds.Name.Equals("campus") && ds.TobeUploaded)
                            {
                                LoadCampus(file);
                            }
                            if (ds.Name.Equals("Depts") && ds.TobeUploaded)
                            {
                                LoadDept(file);
                            }
                            if (ds.Name.Equals("Advisors") && ds.TobeUploaded)
                            {
                                LoadAdvisors(file);
                            }
                        }
                    }
                }
            }
            ViewData["message"] = "Data successfully uploaded";
            return(View("Index"));
        }
        public ActionResult Upload(List<Datasheet> lstDatasheets)
        {
            if (Request != null)
            {
                if (Request.Form["LoadDatasheets"] != null)
                {
                    CCTokenSystemContext dbcontext = new CCTokenSystemContext();
                    HttpPostedFileBase file = Request.Files["DataFileupload"];
                    string fileExtension = System.IO.Path.GetExtension(Request.Files["DataFileupload"].FileName);
                    Session["resourceFile"] = file;
                    if (fileExtension == ".xls" || fileExtension == ".xlsx")
                    {
                        var package = new ExcelPackage(file.InputStream);
                        lstDatasheets = new List<Datasheet>();
                        int id = 0;
                        foreach (ExcelWorksheet ws in package.Workbook.Worksheets)
                        {
                            Datasheet ds = new Datasheet();
                            ds.id = ++id;
                            ds.Name = ws.Name;
                            lstDatasheets.Add(ds);
                        }
                    }
                    else
                    {
                        ViewData["error"] = "Please, Uplaod Excel file only";
                    }
                    return View("Index", lstDatasheets);
                }
                if (Request.Form["LoadData"] != null)
                {
                    if (lstDatasheets != null && lstDatasheets.Count >= 1)
                    {
                        HttpPostedFileBase file = (HttpPostedFileBase)Session["resourceFile"];

                        foreach (Datasheet ds in lstDatasheets)
                        {

                            if (ds.Name.Equals("students") && ds.TobeUploaded)
                            {
                                LoadStudent(file);
                            }
                            if (ds.Name.Equals("campus") && ds.TobeUploaded)
                            {
                                LoadCampus(file);
                            }
                            if (ds.Name.Equals("Depts") && ds.TobeUploaded)
                            {
                                LoadDept(file);
                            }
                            if (ds.Name.Equals("Advisors") && ds.TobeUploaded)
                            {
                                LoadAdvisors(file);
                            }

                        }
                    }
                }
            }
            ViewData["message"] = "Data successfully uploaded";
            return View("Index");
        }