public ActionResult Index(SearchViewModel postedModel) { if (!ModelState.IsValid) return View(postedModel); return RedirectToAction("PreviewResults", new {postedModel.Terms, postedModel.Location, postedModel.Radius}); }
public ActionResult PreviewResults(string terms, string location, int radius ) { var searchResult = new YellowPagesApi().SearchListings(location, terms, radius, 1); var leads = new List<Lead>(); foreach (var listing in searchResult.SearchResult.SearchListings.SearchListing) { var lead = new Lead() { BusinessName = listing.BusinessName, BaseClickUrl = listing.BaseClickUrl, MoreInfoUrl = listing.MoreInfoUrl, Phone = listing.Phone, PrimaryCategory = listing.PrimaryCategory, YpListingId = listing.ListingId, Street = listing.Street, State = listing.State, City = listing.City, Zip = listing.Zip }; leads.Add(lead); } var viewModel = new SearchViewModel(); viewModel.Terms = terms; viewModel.Location = location; viewModel.Radius = radius; if (leads.Any()) { viewModel.Leads = leads; viewModel.ListingsFound = Convert.ToInt32(searchResult.SearchResult.MetaProperties.totalAvailable); } return View(viewModel); }
public ActionResult CreateJob(SearchViewModel postedModel) { var name = postedModel.Name; if(string.IsNullOrWhiteSpace(postedModel.Name)) { name = postedModel.Terms + postedModel.Location + DateTime.Now; } var leadSearch = new LeadSearch() { Location = postedModel.Location, Radius = postedModel.Radius, Terms = postedModel.Terms, UserId = CurrentUser.Id, Name = name, ListingsFound = postedModel.ListingsFound }; RavenSession.Store(leadSearch); RavenSession.SaveChanges(); new QueueManager().AddListingSearch(leadSearch.Id); this.HighFive("Job created successfuly"); return RedirectToAction("LeadSearch", new {id=leadSearch.Id}); }