示例#1
0
        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);
        }
示例#2
0
        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);
        }