public IHttpActionResult GetStundasTema(int id) { StundasTema stundasTema = db.StundasTemas.Find(id); if (stundasTema == null) { return(NotFound()); } return(Ok(new StundasTemaViewModel { Tema_ID = stundasTema.Tema_ID, Tema = stundasTema.Tema, Piezime = stundasTema.Piezime })); }
public IHttpActionResult DeleteStundasTema(int id) { StundasTema stundasTema = db.StundasTemas.Find(id); if (stundasTema == null) { return(NotFound()); } db.StundasTemas.Remove(stundasTema); db.SaveChanges(); return(Ok(new StundasTemaViewModel { Tema_ID = stundasTema.Tema_ID, Tema = stundasTema.Tema, Piezime = stundasTema.Piezime })); }
public IHttpActionResult PostStundasTema(StundasTemaViewModel stundasTemaModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var stundasTema = new StundasTema { Tema_ID = stundasTemaModel.Tema_ID, Tema = stundasTemaModel.Tema, Piezime = stundasTemaModel.Piezime }; db.StundasTemas.Add(stundasTema); try { db.SaveChanges(); } catch (DbUpdateException) { if (StundasTemaExists(stundasTema.Tema_ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("CaptinAmericaApi-StundasTema", new { id = stundasTema.Tema_ID }, new StundasTemaViewModel { Tema_ID = stundasTema.Tema_ID, Tema = stundasTema.Tema, Piezime = stundasTema.Piezime })); }