示例#1
0
        public IHttpActionResult InsertZam(int id, Zamowienie zam1)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            using (SMAPIEntities entities = new SMAPIEntities())
            {
                var numerKlienta = entities.Faktura.Where(p => p.FakturaID == id).FirstOrDefault();

                zam1.KlientID = numerKlienta.KlientID;

                zam1.FakturaID = id;

                var poRabacieTemp = zam1.Cena * (100 - zam1.rabat);

                zam1.PoRabacie = poRabacieTemp / 100;

                var suma = (zam1.PoRabacie * zam1.ilosc);

                zam1.Razem = suma;

                entities.Zamowienie.Add(zam1);


                entities.SaveChanges();
            }

            return(Ok());
        }
示例#2
0
        // PUT: odata/Faktura(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <Faktura> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Faktura faktura = db.Faktura.Find(key);

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

            patch.Put(faktura);

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

            return(Updated(faktura));
        }
示例#3
0
        public IHttpActionResult InsertFakt(Faktura faktura1)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            using (SMAPIEntities entities = new SMAPIEntities())
            {
                entities.Configuration.ProxyCreationEnabled = false;

                var ostatni = entities.Faktura.Max(p => p.FakturaID);

                faktura1.NrFaktury = ostatni + 1 + "/2020";

                faktura1.Klient.numerKlienta = "QWE" + (ostatni + 1).ToString();

                entities.Faktura.Add(faktura1);

                entities.SaveChanges();
            }

            return(Ok(faktura1));
        }