public IHttpActionResult EditTown(int id, [FromBody] AdminTownBindingModel model)
        {
            // Validate the input parameters
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            // Find the town for editing
            var town = this.Data.Towns.All().FirstOrDefault(d => d.Id == id);

            if (town == null)
            {
                return(this.BadRequest("Town #" + id + " not found!"));
            }

            // Modify the town properties
            town.Name = model.Name;

            // Save the changes in the database
            this.Data.Towns.SaveChanges();

            return(this.Ok(
                       new
            {
                message = "Town #" + id + " edited successfully."
            }
                       ));
        }
        public IHttpActionResult CreateNewTown([FromBody] AdminTownBindingModel model)
        {
            // Validate the input parameters
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            // Create new town and assign its properties form the model
            var town = new Town
            {
                Name = model.Name
            };

            // Save the changes in the database
            this.Data.Towns.Add(town);
            this.Data.Towns.SaveChanges();

            return(this.Ok(
                       new
            {
                message = "Town #" + town.Id + " created."
            }
                       ));
        }