Пример #1
0
        /// <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);
        }
Пример #2
0
        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("/");
            };
        }
Пример #3
0
        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);
            };
        }
Пример #4
0
 public void AddLocation(Location location)
 {
     dbRepo.InsertLocation(location);
 }