//public static string DeleteMishap(int mishapId) //{ // try // { // using (var contex = new Garage_of_carsEntities()) // { // contex.Mishaps.Remove(contex.Mishaps.Find(mishapId)); // contex.SaveChanges(); // } // return ("ok"); // } // catch (Exception ex) // { // throw ex; // } //} public static void DeleteMishapByCode(int code) { try { using (garage_of_carsEntities db = new garage_of_carsEntities()) { var mishap = db.Mishaps.First(c => c.mishap_code == code); db.Mishaps.Remove(mishap); db.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static void deleteWorkerByID(int id) { try { using (garage_of_carsEntities db = new garage_of_carsEntities()) { var worker = db.Workers.First(c => c.id_worker == id); db.Workers.Remove(worker); db.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static Mishap InsertMishap(Mishap mishap) { try { using (var context = new garage_of_carsEntities()) { context.Mishaps.Add(mishap); context.SaveChanges(); return(mishap); } } catch (Exception ex) { throw ex; } }