Beispiel #1
0
        public IHttpActionResult PutCountryWithPeople(int id, CountryWithPeople countryWithPeople)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != countryWithPeople.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetCountryWithPeople(int id)
        {
            CountryWithPeople countryWithPeople = db.CountryWithPeoples.Find(id);

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

            return(Ok(countryWithPeople));
        }
Beispiel #3
0
        public IHttpActionResult PostCountryWithPeople(CountryWithPeople countryWithPeople)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CountryWithPeoples.Add(countryWithPeople);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = countryWithPeople.Id }, countryWithPeople));
        }
Beispiel #4
0
        public IHttpActionResult DeleteCountryWithPeople(int id)
        {
            CountryWithPeople countryWithPeople = db.CountryWithPeoples.Find(id);

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

            db.CountryWithPeoples.Remove(countryWithPeople);
            db.SaveChanges();

            return(Ok(countryWithPeople));
        }