コード例 #1
0
        public IHttpActionResult PutAmbalazaStavke(int id, AmbalazaStavke ambalazaStavke)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ambalazaStavke.AmbalazaStavkaID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult GetAmbalazaStavke(int id)
        {
            AmbalazaStavke ambalaza = db.AmbalazaStavke.Find(id);

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

            return(Ok(ambalaza));
        }
コード例 #3
0
        public IHttpActionResult PostAmbalazaStavke(AmbalazaStavke ambalazaStavke)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AmbalazaStavke.Add(ambalazaStavke);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = ambalazaStavke.AmbalazaStavkaID }, ambalazaStavke));
        }
コード例 #4
0
        public IHttpActionResult DeleteAmbalazaStavke(int id)
        {
            AmbalazaStavke ambalazaStavke = db.AmbalazaStavke.Find(id);

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

            db.AmbalazaStavke.Remove(ambalazaStavke);
            db.SaveChanges();

            return(Ok(ambalazaStavke));
        }
コード例 #5
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            bool isValid = true;

            if (cmbAmb.SelectedIndex == -1)
            {
                isValid            = false;
                cmberror.IsVisible = true;
                cmberror.Text      = "Molimo vas odaberite ambalazu ";
            }
            else
            {
                cmberror.IsVisible = false;
            }
            if (txtkolicina.Text == "" || Convert.ToInt32(txtkolicina.Text) == 0)
            {
                isValid = false;
                kolicinaerror.IsVisible = true;
                kolicinaerror.Text      = "Kolicina nije u ispravnom formatu ";
            }
            else
            {
                kolicinaerror.IsVisible = false;
            }
            if (isValid)
            {
                bool           hlp   = true;
                AmbalazaStavke nova  = new AmbalazaStavke();
                AmbalazaStavke temp  = new AmbalazaStavke();
                AmbalazaStavke temp2 = new AmbalazaStavke();
                nova.AmbalazaID   = model._selectedAmbalaza.AmbalazaId;
                nova.Kolicina     = Convert.ToInt32(txtkolicina.Text);
                nova.Brbodova     = model._selectedAmbalaza.Brbodova;
                nova.Naziv        = model._selectedAmbalaza.Naziv;
                nova.Ukupno       = nova.Brbodova * nova.Kolicina;
                nova.IzlazID      = izlazhlp.IzlazID;
                nova.DostavljacID = Global.prijavljeniDostavljac.DostavljacID;
                nova.KupacID      = izlazhlp.KupacID;
                temp = nova;
                foreach (var x in Global.AmbList2)
                {
                    if (nova.AmbalazaID == x.AmbalazaID)
                    {
                        temp2         = x;
                        temp.Kolicina = x.Kolicina + nova.Kolicina;
                        temp.Ukupno   = nova.Brbodova * nova.Kolicina;
                        hlp           = false;
                    }
                }
                if (hlp)
                {
                    Global.AmbList2.Add(nova);
                    IzracunajBodove();
                }
                else
                {
                    Global.AmbList2.Remove(temp2);
                    Global.AmbList2.Add(temp);
                    IzracunajBodove();
                }
            }
        }