private List <CandidateListItems> LoadData() { // Initialization. List <CandidateListItems> lst = new List <CandidateListItems>(); try { lst = CandidatesListExport.ResourceList(); //// Initialization. //string line = string.Empty; //string rootFolderPath = this.Server.MapPath("~/Content/"); //string fileName = "country_list.txt"; //string fullPath = rootFolderPath + fileName; //string srcFilePath = new Uri(fullPath).LocalPath; //StreamReader sr = new StreamReader(new FileStream(srcFilePath, FileMode.Open, FileAccess.Read)); //// Read file. //while ((line = sr.ReadLine()) != null) //{ // // Initialization. // CandidateListItems infoObj = new CandidateListItems(); // string[] info = line.Split(','); // // Setting. // infoObj.ID = Convert.ToInt32(info[0].ToString()); // infoObj.CandidateName = info[1].ToString(); // // Adding. // lst.Add(infoObj); //} // Closing. //sr.Dispose(); //sr.Close(); } catch (Exception ex) { // info. Console.Write(ex); } // info. return(lst); }
public ActionResult Index(MultiSelectDropDownViewModel model) { // Initialization. string filePath = string.Empty; string fileContentType = string.Empty; try { // Verification if (ModelState.IsValid) { // Initialization. List <CandidateListItems> candidateList = this.LoadData(); model.CandidateList = candidateList.Where(p => model.SelectedMultiCandidateId.Contains(p.ID)).Select(q => q).ToList(); List <string> ToDistlist = CandidatesListExport.ResourceNumber(model.CandidateList); string AppendedPhoneList = string.Join(",", ToDistlist.Where(m => !string.IsNullOrEmpty(m)).ToList()); string r = SMSHelperService.SMSService(model.MessageText, AppendedPhoneList); if (r != null) { r = "SMS Sent To Select Receipnts Sucessfully " + r; } Session["ResultMessage"] = r; } // Loading drop down lists. this.ViewBag.CountryList = this.GetCandidateList(); } catch (Exception ex) { // Info Console.Write(ex); } // Info return(this.View(model)); }