コード例 #1
0
        public async Task <IHttpActionResult> PutTB_Countries(int id, TB_Countries tB_Countries)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tB_Countries.IdCountry)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TB_CountriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <IHttpActionResult> GetTB_Countries(int id)
        {
            TB_Countries tB_Countries = await db.TB_Countries.FindAsync(id);

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

            return(Ok(tB_Countries));
        }
コード例 #3
0
        public async Task <IHttpActionResult> PostTB_Countries(TB_Countries tB_Countries)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TB_Countries.Add(tB_Countries);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = tB_Countries.IdCountry }, tB_Countries));
        }
コード例 #4
0
        public async Task <IHttpActionResult> DeleteTB_Countries(int id)
        {
            TB_Countries tB_Countries = await db.TB_Countries.FindAsync(id);

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

            db.TB_Countries.Remove(tB_Countries);
            await db.SaveChangesAsync();

            return(Ok(tB_Countries));
        }