public IHttpActionResult Get() { using (BAZAEntities db = new BAZAEntities()) { var list = db.LAB_SPECIFICNA.Select(lab_specificnaDB => new LabSpecificna { ID = lab_specificnaDB.ID, vremeOd = Convert.ToDateTime(lab_specificnaDB.vremeOd), vremeDo = Convert.ToDateTime(lab_specificnaDB.vremeDo), redosled = lab_specificnaDB.redosled, Id_lab_vezbe = lab_specificnaDB.Id_Lab_vezbe }).ToList(); return(Json(list)); } //string query = @" // select vremeOd, vremeDo, redosled from // dbo.LAB_SPECIFICNA // "; //DataTable table = new DataTable(); //using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) //using (var cmd = new SqlCommand(query, con)) //using (var da = new SqlDataAdapter(cmd)) //{ // cmd.CommandType = CommandType.Text; // da.Fill(table); //} //return Request.CreateResponse(HttpStatusCode.OK, table); }
public IHttpActionResult GetLabVezba(int id) { using (BAZAEntities db = new BAZAEntities()) { var lab_vezbaDB = db.LAB_VEZBA.FirstOrDefault(x => x.ID == id); if (lab_vezbaDB == null) { return(BadRequest()); } var s = new LabVezba { ID = lab_vezbaDB.ID, tag = lab_vezbaDB.tag, naziv = lab_vezbaDB.naziv }; return(Json(s)); } //string query = @" // select tag, naziv from // dbo.LAB_VEZBA where ID=" + id + @" // "; //DataTable table = new DataTable(); //using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) //using (var cmd = new SqlCommand(query, con)) //using (var da = new SqlDataAdapter(cmd)) //{ // cmd.CommandType = CommandType.Text; // da.Fill(table); //} //return Request.CreateResponse(HttpStatusCode.OK, table); }
public IHttpActionResult Get() { using (BAZAEntities db = new BAZAEntities()) { var list = db.LAB_VEZBA.Select(lab_vezbaDB => new LabVezba { ID = lab_vezbaDB.ID, tag = lab_vezbaDB.tag, naziv = lab_vezbaDB.naziv }).ToList(); return(Json(list)); } }
public IHttpActionResult Get() { using (BAZAEntities db = new BAZAEntities()) { var list = db.STUDENTs.Select(studentDB => new Student { ID = studentDB.ID, ime = studentDB.ime, indeks = studentDB.indeks, prezime = studentDB.prezime }).ToList(); return(Json(list)); } }
//ovo mora bolje da se u uslovu stavi i student i lab vezba :D public string Put(CRaspored r) { try { using (BAZAEntities db = new BAZAEntities()) { var rasporedDB = db.RASPOREDs.FirstOrDefault(x => x.id == r.id); rasporedDB.student = r.student; rasporedDB.lab_vezba = r.lab_vezba; rasporedDB.pocetak_laba = Convert.ToDateTime(r.pocetak_laba); rasporedDB.zavrsetak_laba = Convert.ToDateTime(r.zavrsetak_laba); db.SaveChanges(); } return("Updated Successfully!!"); } catch (Exception) { return("Failed to Update!!"); } //try //{ // string query = @" // update dbo.Raspored set student= // '" + r.student + @"', pocetak_laba=" + r.pocetak_laba + @" // where lab_vezba=" + r.lab_vezba + @" // "; // DataTable table = new DataTable(); // using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) // using (var cmd = new SqlCommand(query, con)) // using (var da = new SqlDataAdapter(cmd)) // { // cmd.CommandType = CommandType.Text; // da.Fill(table); // } // return "Updated Successfully!!"; //} //catch (Exception) //{ // return "Failed to Update!!"; //} }
public string Put(LabSpecificna lv) { try { using (BAZAEntities db = new BAZAEntities()) { var lab_specificnaDB = db.LAB_SPECIFICNA.FirstOrDefault(x => x.ID == lv.ID); lab_specificnaDB.vremeOd = lv.vremeOd; lab_specificnaDB.vremeDo = lv.vremeDo; lab_specificnaDB.redosled = lv.redosled; lab_specificnaDB.Id_Lab_vezbe = lv.Id_lab_vezbe; db.SaveChanges(); } return("Updated Successfully!!"); } catch (Exception) { return("Failed to Update!!"); } //try //{ // string query = @" // update dbo.LAB_SPECIFICNA set vremeOd= // " + lv.vremeOd + @", vremeDo=" + lv.vremeDo + @",redosled='" + lv.redosled + @"' // where ID=" + lv.ID + @" // "; // DataTable table = new DataTable(); // using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) // using (var cmd = new SqlCommand(query, con)) // using (var da = new SqlDataAdapter(cmd)) // { // cmd.CommandType = CommandType.Text; // da.Fill(table); // } // return "Updated Successfully!!"; //} //catch (Exception) //{ // return "Failed to Update!!"; //} }
public string Post(Baza.STUDENT s) { try { using (BAZAEntities db = new BAZAEntities()) { db.STUDENTs.Add(s); db.SaveChanges(); } return("Added Successfully!!"); } catch (Exception) { return("Failed to Add!!"); } }
public string Put(LabVezba lv) { try { using (BAZAEntities db = new BAZAEntities()) { var lab_vezbaDB = db.LAB_VEZBA.FirstOrDefault(x => x.ID == lv.ID); lab_vezbaDB.tag = lv.tag; lab_vezbaDB.naziv = lv.naziv; db.SaveChanges(); } return("Updated Successfully!!"); } catch (Exception) { return("Failed to Update!!"); } //try //{ // string query = @" // update dbo.LAB_VEZBA set tag= // '" + lv.tag + @"', naziv='" + lv.naziv + @"' // where ID=" + lv.ID + @" // "; // DataTable table = new DataTable(); // using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) // using (var cmd = new SqlCommand(query, con)) // using (var da = new SqlDataAdapter(cmd)) // { // cmd.CommandType = CommandType.Text; // da.Fill(table); // } // return "Updated Successfully!!"; //} //catch (Exception) //{ // return "Failed to Update!!"; //} }
public string Delete(int id) { try { using (BAZAEntities db = new BAZAEntities()) { var lab_specificnaDB = db.LAB_SPECIFICNA.FirstOrDefault(x => x.ID == id); db.LAB_SPECIFICNA.Remove(lab_specificnaDB); db.SaveChanges(); } return("Deleted Successfully!!"); } catch (Exception) { return("Failed to Delete!!"); } //try //{ // string query = @" // delete from dbo.LAB_SPECIFICNA // where ID=" + indeks + @" // "; // DataTable table = new DataTable(); // using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) // using (var cmd = new SqlCommand(query, con)) // using (var da = new SqlDataAdapter(cmd)) // { // cmd.CommandType = CommandType.Text; // da.Fill(table); // } // return "Deleted Successfully!!"; //} //catch (Exception) //{ // return "Failed to Delete!!"; //} }
public string Delete(int id) { try { using (BAZAEntities db = new BAZAEntities()) { var studentDB = db.STUDENTs.FirstOrDefault(x => x.ID == id); db.STUDENTs.Remove(studentDB); db.SaveChanges(); } return("Deleted Successfully!!"); } catch (Exception) { return("Failed to Delete!!"); } }
public string Post(Baza.RASPORED rs) { try { using (BAZAEntities db = new BAZAEntities()) { db.RASPOREDs.Add(rs); db.SaveChanges(); } return("Added Successfully!!"); } catch (Exception) { return("Failed to Add!!"); } //try //{ // string query = @" // insert into dbo.Raspored values // (" + rs.student + @", " + rs.lab_vezba + @", " + rs.pocetak_laba + @") // "; // DataTable table = new DataTable(); // using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) // using (var cmd = new SqlCommand(query, con)) // using (var da = new SqlDataAdapter(cmd)) // { // cmd.CommandType = CommandType.Text; // da.Fill(table); // } // return "Added Successfully!!"; //} //catch (Exception) //{ // return "Failed to Add!!"; //} }
public string Post(Baza.LAB_SPECIFICNA lv) { try { using (BAZAEntities db = new BAZAEntities()) { db.LAB_SPECIFICNA.Add(lv); db.SaveChanges(); } return("Added Successfully!!"); } catch (Exception) { return("Failed to Add!!"); } //try //{ // string query = @" // insert into dbo.LAB_SPECIFICNA values // (" + lv.vremeOd + @", " + lv.vremeDo + @",'" + lv.redosled + @"'," + lv.Id_lab_vezbe + @") // "; // DataTable table = new DataTable(); // using (var con = new SqlConnection(ConfigurationManager. // ConnectionStrings["AppDB"].ConnectionString)) // using (var cmd = new SqlCommand(query, con)) // using (var da = new SqlDataAdapter(cmd)) // { // cmd.CommandType = CommandType.Text; // da.Fill(table); // } // return "Added Successfully!!"; //} //catch (Exception) //{ // return "Failed to Add!!"; //} }
public IHttpActionResult GetStudent(int id) { using (BAZAEntities db = new BAZAEntities()) { var studentDB = db.STUDENTs.FirstOrDefault(x => x.ID == id); if (studentDB == null) { return(BadRequest()); } var s = new Student { ID = studentDB.ID, ime = studentDB.ime, indeks = studentDB.indeks, prezime = studentDB.prezime }; return(Json(s)); } }
public string Put(Student s) { try { using (BAZAEntities db = new BAZAEntities()) { var studentDB = db.STUDENTs.FirstOrDefault(x => x.ID == s.ID); studentDB.ime = s.ime; studentDB.prezime = s.prezime; studentDB.indeks = s.indeks; db.SaveChanges(); } return("Updated Successfully!!"); } catch (Exception) { return("Failed to Update!!"); } }