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

            if (id != view_Country.ID)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public IHttpActionResult PostView_Country(View_Country view_Country)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.View_Country.Add(view_Country);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = view_Country.ID }, view_Country);
        }