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 NewLoc(string name, string region, string evGain, string distance, string startN, string startW, string endN, string endW, string pDiff, string TDiff, string peakEv, string verified, string description) { int ev_gain = 0; float dist = 0; int physical = 0; int technical = 0; int final = 0; //bool ver = false; **currently recieves this as null, possibly due to the diabled attribute in the html Coordinate start = null; Coordinate end = null; try { ev_gain = int.Parse(evGain); dist = float.Parse(distance); physical = int.Parse(pDiff); technical = int.Parse(TDiff); final = int.Parse(peakEv); //ver = bool.Parse(verified); start = new Coordinate(double.Parse(startN), double.Parse(startW)); end = new Coordinate(double.Parse(endN), double.Parse(endW)); } catch (Exception ex) { Utilities.ExceptionLogger("Unparseable input in NewLoc function. Exception message: " + ex.Message); } Location newLoc = new Location(0, name, region, ev_gain, dist, start, end, physical, technical, final, 0 /*for now a new location is always unverified*/, description); LocationConnect lc = new LocationConnect(); Message response = lc.AddLocation(newLoc); if (response.GetResult()) { Utilities.EventLogger("Created a new location named: " + name, Globals.LOG_LEVELS.Info); return(View("Created")); } else { Utilities.EventLogger("Couldn't create a new location named: " + name + " Resulting message: " + response.GetText(), Globals.LOG_LEVELS.Error); ViewBag.createdlocationResponse = response.GetText(); return(View("NewLocation")); } }
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()); }