コード例 #1
0
        public IHttpActionResult PostVaccine_Table(Vaccine_Table vaccine_Table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Vaccine_Table.Add(vaccine_Table);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (Vaccine_TableExists(vaccine_Table.Vaccine_nr))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = vaccine_Table.Vaccine_nr }, vaccine_Table));
        }
コード例 #2
0
        public IHttpActionResult PutVaccine_Table(int id, Vaccine_Table vaccine_Table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vaccine_Table.Vaccine_nr)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult GetVaccine_Table(int id)
        {
            Vaccine_Table vaccine_Table = db.Vaccine_Table.Find(id);

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

            return(Ok(vaccine_Table));
        }
コード例 #4
0
        public IHttpActionResult DeleteVaccine_Table(int id)
        {
            Vaccine_Table vaccine_Table = db.Vaccine_Table.Find(id);

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

            db.Vaccine_Table.Remove(vaccine_Table);
            db.SaveChanges();

            return(Ok(vaccine_Table));
        }