예제 #1
0
        public IHttpActionResult PostpostnrBy(postnrBy postnrBy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.postnrBy.Add(postnrBy);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (postnrByExists(postnrBy.Postnr))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = postnrBy.Postnr }, postnrBy));
        }
예제 #2
0
        public IHttpActionResult PutpostnrBy(int id, postnrBy postnrBy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != postnrBy.Postnr)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public IHttpActionResult GetpostnrBy(int id)
        {
            postnrBy postnrBy = db.postnrBy.Find(id);

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

            return(Ok(postnrBy));
        }
예제 #4
0
        public IHttpActionResult DeletepostnrBy(int id)
        {
            postnrBy postnrBy = db.postnrBy.Find(id);

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

            db.postnrBy.Remove(postnrBy);
            db.SaveChanges();

            return(Ok(postnrBy));
        }