Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            //display items
            var db       = new DataAccess.Models.CSharpContext();
            var keywords = db.Keywords;

            foreach (var k in keywords)
            {
                System.Console.WriteLine("{0} - {1}", k.Parent.Name, k.Name);
            }
            System.Console.ReadLine();
            foreach (var c in db.Contacts)
            {
                System.Console.WriteLine("{0} {1} - {2}", c.FirstName, c.LastName, c.Keyword.Name);
                foreach (var item in c.ContactMethods)
                {
                    System.Console.WriteLine("\t -- {0} {1} ", item.Keyword.Name, item.Value);
                }
            }
            //add item
            System.Console.WriteLine("Enter a contact in the following format (FirstName LastName Phone)");
            var results = System.Console.ReadLine();
            var values  = results.Split();
            var contact = new DataAccess.Models.Contact {
                FirstName = values[0], LastName = values[1], KeywordsId = 5
            };

            db.Contacts.Add(contact);
            contact.ContactMethods.Add(new DataAccess.Models.ContactMethod {
                KeywordID = 7, Value = values[2]
            });
            db.SaveChanges();

            /*
             * System.Console.WriteLine("Hello World");
             * //System.Console.ReadLine();
             * System.Console.WriteLine("What is your username");
             * var response = System.Console.ReadLine();
             *
             * System.Console.WriteLine("Here's your profile info");
             * System.Console.Write(GetProfile(response)+"\n");
             *
             * var db = new DataAccess.Test1Entities();
             * foreach (var item in db.Contacts) {
             *  System.Console.WriteLine(item.FirstName + " " + item.LastName);
             * }
             * System.Console.ReadLine();
             */
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            //display items
            var db = new DataAccess.Models.CSharpContext();
            var keywords = db.Keywords;
            foreach (var k in keywords) {
                System.Console.WriteLine("{0} - {1}", k.Parent.Name, k.Name);
            }
            System.Console.ReadLine();
            foreach (var c in db.Contacts) {
                System.Console.WriteLine("{0} {1} - {2}", c.FirstName, c.LastName, c.Keyword.Name);
                foreach (var item in c.ContactMethods) {
                    System.Console.WriteLine("\t -- {0} {1} ", item.Keyword.Name, item.Value);
                }
            }
            //add item
            System.Console.WriteLine("Enter a contact in the following format (FirstName LastName Phone)");
            var results = System.Console.ReadLine();
            var values = results.Split();
            var contact = new DataAccess.Models.Contact {FirstName = values[0], LastName = values[1], KeywordsId = 5 };
            db.Contacts.Add(contact);
            contact.ContactMethods.Add(new DataAccess.Models.ContactMethod {KeywordID = 7, Value= values[2] });
            db.SaveChanges();
            /*
            System.Console.WriteLine("Hello World");
            //System.Console.ReadLine();
            System.Console.WriteLine("What is your username");
            var response = System.Console.ReadLine();

            System.Console.WriteLine("Here's your profile info");
            System.Console.Write(GetProfile(response)+"\n");

            var db = new DataAccess.Test1Entities();
            foreach (var item in db.Contacts) {
                System.Console.WriteLine(item.FirstName + " " + item.LastName);
            }
            System.Console.ReadLine();
             */
        }