예제 #1
0
        public IHttpActionResult PutPopusti(int id, Popusti popusti)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != popusti.popID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GetPopusti(int id)
        {
            Popusti popusti = db.Popustis.Find(id);

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

            return(Ok(popusti));
        }
예제 #3
0
        public IHttpActionResult PostPopusti(Popusti popusti)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Popustis.Add(popusti);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = popusti.popID }, popusti));
        }
예제 #4
0
        public IHttpActionResult AddDiscount([FromBody] PopustNaLiniji discountOnLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            Popusti discount = discountOnLine.Popusti;

            int discountId = _database.Add_Discount(discount.Postotak, discount.DatumVazenjaPopusta);

            _database.Add_Discount_On_Line(discountId, discountOnLine.LinijeId, discountOnLine.Opis);
            return(Ok());
        }
예제 #5
0
        public IHttpActionResult DeletePopusti(int id)
        {
            Popusti popusti = db.Popustis.Find(id);

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

            db.Popustis.Remove(popusti);
            db.SaveChanges();

            return(Ok(popusti));
        }
예제 #6
0
 public void KreirajPopust()
 {
     Popusti.Add(new Tuple <string, int>(SifraPopusta, PopustKolicina));
 }