Esempio n. 1
0
        public IHttpActionResult PutDostawa(int id, Dostawa dostawa)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dostawa.id_dostawa)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult PutProdukt(int id, Produkt produkt)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != produkt.id_produkt)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public IHttpActionResult PutAdre(int id, Adre adre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != adre.id_adres)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 4
0
 public IHttpActionResult DeleteCountryById(string id)
 {
     using (var ctx = new SklepEntities())
     {
         var country = ctx.Kraje.Where(I => I.Kraj_id == id).FirstOrDefault();
         ctx.Entry(country).State = System.Data.Entity.EntityState.Deleted;
         ctx.SaveChanges();
     }
     return(Ok());
 }
Esempio n. 5
0
        public IHttpActionResult DeleteInvoiceById(int id)
        {
            if (id < 0)
            {
                return(BadRequest("Invalid id"));
            }

            using (var ctx = new SklepEntities())
            {
                var Invoice = ctx.Faktury.Where(I => I.Faktura_id == id).FirstOrDefault();
                ctx.Entry(Invoice).State = System.Data.Entity.EntityState.Deleted;
                ctx.SaveChanges();
            }
            return(Ok());
        }
 public IHttpActionResult DeleteSupplierById(string id)
 {
     using (var ctx = new SklepEntities())
     {
         if (ctx.Faktury.Include("Dostawca").Any(K => K.Dostawca_id == id))
         {
             return(BadRequest("Id exists"));
         }
         {
             var supplier = ctx.Dostawcy.Where(I => I.Dostawca_id == id).FirstOrDefault();
             ctx.Entry(supplier).State = System.Data.Entity.EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     return(Ok());
 }
 public IHttpActionResult DeleteRecipientById(string id)
 {
     using (var ctx = new SklepEntities())
     {
         if (ctx.Faktury.Include("Odbiorca_id").Any(K => K.Odbiorca_id == id))
         {
             return(BadRequest("Id exists"));
         }
         {
             var recipient = ctx.Odbiorcy.Where(I => I.Odbiorca_id == id).FirstOrDefault();
             ctx.Entry(recipient).State = System.Data.Entity.EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     return(Ok());
 }
        public IHttpActionResult DeleteDuckById(int id)
        {
            if (id < 0)
            {
                return(BadRequest("Invalid id"));
            }

            using (var ctx = new SklepEntities())
            {
                if (ctx.Faktury.Include("Kaczka_id").Any(K => K.Kaczka_id == id))
                {
                    return(BadRequest("Id exists"));
                }
                else
                {
                    var duck = ctx.Kaczki.Where(I => I.Kaczka_id == id).FirstOrDefault();
                    ctx.Entry(duck).State = System.Data.Entity.EntityState.Deleted;
                    ctx.SaveChanges();
                }
            }
            return(Ok());
        }
Esempio n. 9
0
        public IHttpActionResult DeleteEmployeeById(int id)
        {
            if (id < 0)
            {
                return(BadRequest("Invalid id"));
            }

            using (var ctx = new SklepEntities())
            {
                if (ctx.Faktury.Include("Pracownik_id").Any(K => K.Pracownik_id == id))
                {
                    return(BadRequest("Id exists"));
                }
                else
                {
                    var Employee = ctx.Pracownicy.Where(I => I.Pracownik_id == id).FirstOrDefault();
                    ctx.Entry(Employee).State = System.Data.Entity.EntityState.Deleted;
                    ctx.SaveChanges();
                }
            }
            return(Ok());
        }