Пример #1
0
        public IHttpActionResult PostGatavaShemaModulis(GatavaShemaModulis gatavaShemaModulis)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.GatavasShemasModulis.Add(gatavaShemaModulis);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (GatavaShemaModulisExists(gatavaShemaModulis.Gatavā_shēma_moduļa_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("BatmanApi-GatavaShemaModulis", new { id = gatavaShemaModulis.Gatavā_shēma_moduļa_ID }, gatavaShemaModulis));
        }
Пример #2
0
        public IHttpActionResult PutGatavaShemaModulis(int id, GatavaShemaModulis gatavaShemaModulis)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gatavaShemaModulis.Gatavā_shēma_moduļa_ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public IHttpActionResult GetGatavaShemaModulis(int id)
        {
            GatavaShemaModulis gatavaShemaModulis = db.GatavasShemasModulis.Find(id);

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

            return(Ok(gatavaShemaModulis));
        }
Пример #4
0
        public IHttpActionResult DeleteGatavaShemaModulis(int id)
        {
            GatavaShemaModulis gatavaShemaModulis = db.GatavasShemasModulis.Find(id);

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

            db.GatavasShemasModulis.Remove(gatavaShemaModulis);
            db.SaveChanges();

            return(Ok(gatavaShemaModulis));
        }