Ejemplo n.º 1
0
        public IHttpActionResult Post(EBaseSize eBaseSize)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.EBaseSizes.Add(eBaseSize);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (EBaseSizeExists(eBaseSize.base_requirement_id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = eBaseSize.base_requirement_id }, eBaseSize));
        }
Ejemplo n.º 2
0
        public IHttpActionResult Put(int id, EBaseSize eBaseSize)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != eBaseSize.base_requirement_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult Get(int id)
        {
            EBaseSize eBaseSize = db.EBaseSizes.Find(id);

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

            return(Ok(eBaseSize));
        }
Ejemplo n.º 4
0
        public IHttpActionResult Delete(int id)
        {
            EBaseSize eBaseSize = db.EBaseSizes.Find(id);

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

            db.EBaseSizes.Remove(eBaseSize);
            db.SaveChanges();

            return(Ok(eBaseSize));
        }