//public ActionResult Results(FormCollection col) public async System.Threading.Tasks.Task <ActionResult> GetResults(SearchData sData) //async { try { sData.ValidateInput(); if (sData.ValidationSuccessful) { sData.CreateSearchString(); Saver.Save(sData); await sData.SearchAsync(1); if (sData.ResultList.Count() > 0) { await sData.SearchAsync(2); await sData.SearchAsync(3); ViewBag.FileStatus = string.Format("{0} found.", sData.ResultList.Count()); return(View(sData)); } else { ViewBag.FileStatus = "No listings found."; return(View("Index", sData)); } } else { ViewBag.FileStatus = sData.Information; return(View("Index", sData)); } } catch (Exception e) { ViewBag.FileStatus = "Error"; sData.Error(); return(View("Index", sData)); } }
public ActionResult Document(ReportDocument document) { if (ModelState.IsValid) { document.DateStored = DateTime.Now; if (document.Public) { if (document.File != null) { string fileExt = Path.GetExtension(document.File.FileName).ToUpper().Replace(".", string.Empty); string[] AcceptedFileExtenstions = System.Configuration.ConfigurationManager.AppSettings["FileExtensions"]. ToUpper(). Replace(" ", string.Empty). Split(','); bool FileExtAccepted = AcceptedFileExtenstions.Any(x => x == fileExt); if (FileExtAccepted) { //Report report = new Report(); // Remove? Saver.SaveFile(document); ViewBag.ModelStatus = string.Format("Success. {0} saved.", document.Name); return(View("Document", new ReportDocument())); } else { string fileFormats = "."; fileFormats += AcceptedFileExtenstions[0].ToLower(); int n = AcceptedFileExtenstions.Length; for (int i = 1; i < n - 1; i++) { fileFormats += ", ."; fileFormats += AcceptedFileExtenstions[i].ToLower(); } fileFormats += " or ."; fileFormats += AcceptedFileExtenstions[n - 1].ToLower(); ViewBag.ModelStatus = string.Format("Wrong file format. Only {0} files are accepted", fileFormats); return(View("Document", document)); } } else { if (document.ExternalLink != null) { Saver.Save(document); ViewBag.ModelStatus = string.Format("Success. {0} saved.", document.Name); return(View("Document", new ReportDocument())); } else { ViewBag.ModelStatus = "You have to input source or upload file as PDF"; return(View("Document", document)); } } } else { ViewBag.ModelStatus = "You cannot upload data that is not public"; } } return(View("Document", document)); }