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)); }
public IHttpActionResult GetPopusti(int id) { Popusti popusti = db.Popustis.Find(id); if (popusti == null) { return(NotFound()); } return(Ok(popusti)); }
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)); }
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()); }
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)); }
public void KreirajPopust() { Popusti.Add(new Tuple <string, int>(SifraPopusta, PopustKolicina)); }