public IHttpActionResult PutUcionica(int id, Ucionica ucionica) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ucionica.UcionicaId) { return(BadRequest()); } db.Entry(ucionica).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UcionicaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutOcjenaStudent(int id, OcjenaStudent ocjenaStudent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ocjenaStudent.OcjenaStudentId) { return(BadRequest()); } db.Entry(ocjenaStudent).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OcjenaStudentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutRadnoStanje(int id, RadnoStanje radnoStanje) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != radnoStanje.RadnoStanjeId) { return(BadRequest()); } db.Entry(radnoStanje).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RadnoStanjeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutStudent(int id, Student student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != student.StudentId) { return(BadRequest()); } db.Entry(student).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception ex) { SqlException greska = ex.InnerException as SqlException; if (greska != null) { return(BadRequest(Util.ExceptionHandler.DbUpdateExceptionHandler(greska))); } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutKorisnickiNalog(int id, KorisnickiNalog korisnickiNalog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != korisnickiNalog.KorisnickiNalogId) { return(BadRequest()); } db.Entry(korisnickiNalog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!KorisnickiNalogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutZahtjev(int id, Zahtjev zahtjev) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != zahtjev.ZahtjevId) { return(BadRequest()); } db.Entry(zahtjev).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ZahtjevExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutBanPrijavaTutor(int id, BanPrijavaTutor banPrijavaTutor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != banPrijavaTutor.PrijavaTutorId) { return(BadRequest()); } db.Entry(banPrijavaTutor).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BanPrijavaTutorExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutPodkategorija(int id, Podkategorija podkategorija) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != podkategorija.PodKategorijaId) { return(BadRequest()); } db.Entry(podkategorija).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PodkategorijaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutGrad(int id, Grad grad) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != grad.GradId) { return(BadRequest()); } db.Entry(grad).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GradExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutMaterijal(int id, Materijal materijal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != materijal.MaterijalId) { return(BadRequest()); } db.Entry(materijal).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MaterijalExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void updateappo(int task_id) { Model.Task task = (from p in db.Task where p.Task_id == task_id select p).FirstOrDefault(); task.appo_count += 1; db.SaveChanges(); }
public IHttpActionResult PutKorisnickiNalog(int id, KontaktInfo kontaktInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != kontaktInfo.KontaktInfoId) { return(BadRequest()); } db.Entry(kontaktInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { if (!KontaktInfoExists(id)) { return(NotFound()); } else { var nesto = ex.GetType().ToString(); SqlException greska = ex.InnerException as SqlException; if (greska != null) { return(BadRequest(Util.ExceptionHandler.DbUpdateExceptionHandler(greska))); } } } return(StatusCode(HttpStatusCode.NoContent)); }
public void insertstudent(Student student) { db.Student.Add(student); db.SaveChanges(); }
public IHttpActionResult PostTutor(Tutor t) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } KorisnickiNalog kNalog = new KorisnickiNalog() { KorisnickoIme = t.KorisnickoIme, LozinkaSalt = t.LozinkaSalt, LozinkaHash = t.LozinkaHash }; db.KorisnickiNalogs.Add(kNalog); try { db.SaveChanges(); } catch (DbUpdateException ex) { SqlException greska = ex.InnerException.InnerException as SqlException; if (greska != null) { return(BadRequest(Util.ExceptionHandler.DbUpdateExceptionHandler(greska))); } } KontaktInfo kontak = new KontaktInfo() { Email = t.Email, Telefon = t.Telefon, Adresa = t.Adresa }; try { db.KontaktInfoes.Add(kontak); } catch (DbUpdateException ex) { db.KorisnickiNalogs.Remove(kNalog); SqlException greska = ex.InnerException.InnerException as SqlException; if (greska != null) { return(BadRequest(Util.ExceptionHandler.DbUpdateExceptionHandler(greska))); } } Tutor noviTutor = new Tutor() { Ime = t.Ime, Prezime = t.Prezime, DatumDodavanja = DateTime.Today, DatumRodjenja = t.DatumRodjenja, NazivUstanove = t.NazivUstanove, SpolId = t.SpolId, GradId = t.GradId, RadnoStanjeId = t.RadnoStanjeId, TutorTitulaId = t.TutorTitulaId, PodKategorijaId = t.PodKategorijaId, CijenaCasa = t.CijenaCasa, TutorSlika = t.TutorSlika, TutorTumbnail = t.TutorTumbnail, SlikaOdobrenja = t.SlikaOdobrenja, StatusKorisnickoRacunaId = t.StatusKorisnickoRacunaId, KorisnickiNalogId = kNalog.KorisnickiNalogId, KontaktInfoId = kontak.KontaktInfoId }; try { db.Tutors.Add(noviTutor); } catch (DbUpdateException ex) { db.KorisnickiNalogs.Remove(kNalog); db.KontaktInfoes.Remove(kontak); SqlException greska = ex.InnerException.InnerException as SqlException; if (greska != null) { return(BadRequest(Util.ExceptionHandler.DbUpdateExceptionHandler(greska))); } } foreach (var vrstaSudenta in t.TipStudenta) { ObimStudent tipStudenta = new ObimStudent() { TutorId = noviTutor.TutorId, TipStudentaId = vrstaSudenta.TipoviStudentaId }; db.ObimStudents.Add(tipStudenta); } try { db.SaveChanges(); } catch (DbUpdateException ex) { SqlException greska = ex.InnerException.InnerException as SqlException; if (greska != null) { return(BadRequest(Util.ExceptionHandler.DbUpdateExceptionHandler(greska))); } } return(Created("api/Tutor", noviTutor));//koricenje Creted radi neobicnog ponasanja API }