コード例 #1
0
        public IHttpActionResult PutCitiesHavePopulation(int id, CitiesHavePopulation citiesHavePopulation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != citiesHavePopulation.PUID)
            {
                return(BadRequest());
            }

            db.Entry(citiesHavePopulation).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CitiesHavePopulationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult GetCitiesHavePopulation(int id)
        {
            CitiesHavePopulation citiesHavePopulation = db.CitiesHavePopulations.Find(id);

            if (citiesHavePopulation == null)
            {
                return(NotFound());
            }

            return(Ok(citiesHavePopulation));
        }
コード例 #3
0
        public IHttpActionResult PostCitiesHavePopulation(CitiesHavePopulation citiesHavePopulation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CitiesHavePopulations.Add(citiesHavePopulation);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = citiesHavePopulation.PUID }, citiesHavePopulation));
        }
コード例 #4
0
        public IHttpActionResult DeleteCitiesHavePopulation(int id)
        {
            CitiesHavePopulation citiesHavePopulation = db.CitiesHavePopulations.Find(id);

            if (citiesHavePopulation == null)
            {
                return(NotFound());
            }

            db.CitiesHavePopulations.Remove(citiesHavePopulation);
            db.SaveChanges();

            return(Ok(citiesHavePopulation));
        }