public static bool RemoveDrivingLicence(int idDrivingLicence) { KATEGORIEPJAZDY drivingLicence = new KATEGORIEPJAZDY() { idKatPJ = idDrivingLicence }; using (var entities = new DBEntities()) { try { entities.KATEGORIEPJAZDY.Attach(drivingLicence); entities.KATEGORIEPJAZDY.Remove(drivingLicence); entities.SaveChanges(); } catch (Exception) { if (!entities.KATEGORIEPJAZDY.Any(i => i.idKatPJ == idDrivingLicence)) { return(false); } } } return(true); }
public static bool AddDrivingLicence(KATEGORIEPJAZDY newDrivingLicence) { using (var entities = new DBEntities()) { entities.KATEGORIEPJAZDY.Add(newDrivingLicence); entities.SaveChanges(); } return(true); }