/// <summary> /// Creates specified location into the database. /// </summary> /// <param name="location">Location to be inserted</param> public void InsertLocation(Location location) { int id = _dbConnection.Query<int>( @"insert into location(Title, Latitude, Longitude) values (@Title, @Latitude, @Longitude); select cast(LAST_INSERT_ID() as unsigned)", param: location).Single(); var rows = location.Keywords.Select(x => new { ID_location = id, Keyword = x }); _dbConnection.Execute( @"insert into locationkeyword(ID_Location, Keyword) values (@ID_location, @Keyword)", param: rows); }
public IndexModule() { Get["/"] = parameters => { var model = new Location(); return View["index.html", model]; }; Post["/addLocation"] = parameters => { //TODO: validation var location = this.Bind<Location>(); new ModelFactory().AddLocation(location); return Response.AsRedirect("/"); }; }
public SearchModule() : base("/search") { Get["/"] = parameters => { var model = new Location(); return View["index.html", model]; }; Get["/searchLocation"] = parameters => { //TODO: validation string criteria = Request.Query["term"].Value; List<Location> result = new ModelFactory().SearchLocation(criteria); return Response.AsJson(result); }; }
public void AddLocation(Location location) { dbRepo.InsertLocation(location); }