public int Delete() { var db = ObjectProvider.MakeDbInstance(); Console.Write("Enter email's id: "); int id = int.Parse(Console.ReadLine()); db.Remove(db.Emails.FirstOrDefault(x => x.Id == id)); db.SaveChanges(); return(id); }
public int Add() { var db = ObjectProvider.MakeDbInstance(); Email anEmail = ObjectProvider.MakeEmailInstance(); Console.Write("Enter email address: "); anEmail.ContactTitle = Console.ReadLine(); Console.Write("Enter the id of belonging phonebook: "); anEmail.PhonebookId = int.Parse(Console.ReadLine()); db.Add(anEmail); db.SaveChanges(); return(anEmail.Id); }