Esempio n. 1
0
        public async Task <IHttpActionResult> PutAdmixtures(int id, Admixtures admixtures)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != admixtures.IngredientsId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> GetAdmixtures(int id)
        {
            Admixtures admixtures = await db.Admixtures.FindAsync(id);

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

            return(Ok(admixtures));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> PostAdmixtures(Admixtures admixtures)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Admixtures.Add(admixtures);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = admixtures.IngredientsId }, admixtures));
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> DeleteAdmixtures(int id)
        {
            Admixtures admixtures = await db.Admixtures.FindAsync(id);

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

            db.Admixtures.Remove(admixtures);
            await db.SaveChangesAsync();

            return(Ok(admixtures));
        }