Пример #1
0
        public IHttpActionResult PutAtelie(int id, Atelie atelie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != atelie.atelieID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult PostAtelie(Atelie atelie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Atelie.Add(atelie);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (AtelieExists(atelie.atelieID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = atelie.atelieID }, atelie));
        }
Пример #3
0
        public IHttpActionResult DeleteAtelie(int id)
        {
            Atelie atelie = db.Atelie.Find(id);

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

            db.Atelie.Remove(atelie);
            db.SaveChanges();

            return(Ok(atelie));
        }