public ActionResult Index(UploadViewModel model) { ViewBag.ShowResult = false; ViewBag.TotalCount = "P"; model.TotalCount = ""; if (ModelState.IsValid) { var fileName = Path.GetFileName(model.File.FileName); if (fileName.ToUpper().EndsWith(".XLSX") || fileName.ToUpper().EndsWith(".CSV")) { if (model.File.ContentLength > 0) { var database = new DataPersistance(); database.CleanTable(); var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); model.File.SaveAs(path); var ts = data.GetData(path,model.IsFirstRowAsColumnName); var lists = invalidator.ValidatedData(ts); model.TotalCount = "Total count: " + ts.Count() + ", Please click below to view details."; Session["Errors"] = lists; Session["Count"] = ts.Count(); return RedirectToAction("index","Transaction"); } return View("index"); } } return View("index"); }
public ValiateData() { this.validator = new Validate(); database= new DataPersistance(); }