コード例 #1
0
        public IHttpActionResult PostKabinets(Kabineti kabinets)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Kabinets.Add(kabinets);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (KabinetsExists(kabinets.Elektronika))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("WolverineApi-Kabinets", new { id = kabinets.Elektronika }, kabinets));
        }
コード例 #2
0
        public IHttpActionResult PutKabinets(string id, Kabineti kabinets)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != kabinets.Elektronika)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult GetKabinets(string id)
        {
            Kabineti kabinets = db.Kabinets.Find(id);

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

            return(Ok(kabinets));
        }
コード例 #4
0
        public IHttpActionResult DeleteKabinets(string id)
        {
            Kabineti kabinets = db.Kabinets.Find(id);

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

            db.Kabinets.Remove(kabinets);
            db.SaveChanges();

            return(Ok(kabinets));
        }