public IHttpActionResult PostNagrade(Nagrade obj) { if (!ModelState.IsValid) { return(BadRequest()); } dm.Nagrade.Add(obj); dm.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = obj.NagradaID }, obj)); }
public IzmijeniNagradu(int nagradaid) { InitializeComponent(); HttpResponseMessage response = nagradeService.GetResponse(nagradaid.ToString()); if (response.StatusCode == System.Net.HttpStatusCode.NotFound) { n = null; } else if (response.IsSuccessStatusCode) { n = response.Content.ReadAsAsync <Nagrade>().Result; } }
public IHttpActionResult PutNagrade(int id, Nagrade n) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != n.NagradaID) { return(BadRequest()); } dm.esp_Nagrade_Update(id, n.Naziv, n.Od, n.Do); dm.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }