public ActionResult SearchLoc(string keyword) { LocationConnect lc = new LocationConnect(); Message response = lc.SearchLocation(keyword, Globals.LOCATION_SEARCHABLE_ATTRIBUTES.Name); if (response.GetResult()) { //somehow return the payload of the message - List<Location> - to the page as clickable links ViewBag.locList = (List <Location>)response.GetPayload(); return(View("Index")); } else { ViewBag.locList = new List <Location>(); //bit of hack, returning null and a list with no items have differnt meanings to the logic in the cshtml return(View("Index")); } }
public ActionResult ShowLocation(string id) { LocationConnect lc = new LocationConnect(); Message response = lc.SearchLocation(id, Globals.LOCATION_SEARCHABLE_ATTRIBUTES.ID); if (!response.GetResult()) { ViewBag.ErrorMessage = "Unable to find the given location."; return(View("Error")); } else { List <Location> locList = (List <Location>)response.GetPayload(); if (locList.Count > 1) //This should realisiticly never happen { ViewBag.ErrorMessage = "Something has gone worng in the location database"; Utilities.EventLogger("Found more than one location with the same id trying to show a location.", Globals.LOG_LEVELS.Critical); return(View("Error")); } ViewBag.searchLocationResult = locList.ElementAt(0); Globals.PRESENT_LOC = locList.ElementAt(0); CommentConnect cc = new CommentConnect(); Message commentResponse = cc.GetLocationComments(id); if (commentResponse.GetResult()) { List <Comment> commList = (List <Comment>)commentResponse.GetPayload(); ViewBag.locationCommentResult = commList; } else { ViewBag.locationCommentError = commentResponse.GetText(); } } return(View()); }