private static void InsertData(Series s) { using (var db = new SeriesContext()) { db.Series.Add(s); db.SaveChanges(); } }
private static void UpdateSeries() { using (var db = new SeriesContext()) { Console.WriteLine("Please enter the id for which you want to update the record"); int id = Convert.ToInt32(Console.ReadLine()); s = GetSeriesById(id); Console.WriteLine(s.ToString()); s = AcceptDetails(); db.Entry(s).State = EntityState.Modified; db.SaveChanges(); Console.WriteLine("Data Updated SuccessFully"); } }
private static void DeleteRecord() { using (var db = new SeriesContext()) { Console.WriteLine("Please enter the id that needed to be deleted"); int id = Convert.ToInt32(Console.ReadLine()); s = GetSeriesById(id); if (s == null) { Console.WriteLine("No records found"); } db.Series.Remove(s); db.SaveChanges(); } }