public String ajouterLBS(ligne_bs lBl) { String resultat = "Ok"; using (NewCampusEntities db = new NewCampusEntities()) { if (this.testAjouterLBS(lBl) == false) { try { db.ligne_bs.Add(lBl); db.SaveChanges(); } catch (Exception e) { resultat = e.Message; } } else { resultat = "LF existante "; } } return(resultat); }
public string supprimerLBS(List <ligne_bs> listp) { String resultat = "OK"; foreach (ligne_bs aX in listp) { using (NewCampusEntities db = new NewCampusEntities()) { try { if (aX.id > 0) { ligne_bs artX = db.ligne_bs.Single(a => a.id == aX.id); db.ligne_bs.Remove(artX); db.SaveChanges(); } } catch (Exception) { resultat = resultat + "," + aX.id; db.Dispose(); } } } return(resultat); }
public Boolean testAjouterLBS(ligne_bs b) { Boolean trouve = true; //string s = cli.code; using (NewCampusEntities db = new NewCampusEntities()) { try { var cx = db.ligne_bs.Single(c => c.id.Equals(b.id)); if (cx == null) { trouve = false; } } catch (Exception) { trouve = false; } } return(trouve); }