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

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

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

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

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

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

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

            db.tNutrientTypes.Add(NutrientType);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = NutrientType.ID }, NutrientType));
        }
コード例 #4
0
        public async Task <IHttpActionResult> DeletetNutrientType(int id)
        {
            tNutrientType tNutrientType = await db.tNutrientTypes.FindAsync(id);

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

            db.tNutrientTypes.Remove(tNutrientType);
            await db.SaveChangesAsync();

            return(Ok(tNutrientType));
        }