//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 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!!"); } }