public void Execute()
 {
     try
     {
         using (var context = new ContextClass())
         {
             var dept = new Department
             {
                 deptName = "Accounting"
             };
             context.Departments.Add(dept);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 2
0
        public void Execute()
        {
            try
            {
                using (var context = new ContextClass())
                {
                    var employee = new Employee();
                    Console.WriteLine("enter empName");
                    employee.empName = Console.ReadLine();
                    Console.WriteLine("enter empLoc");
                    employee.empLoc = Console.ReadLine();
                    Console.WriteLine("enter the deptId");
                    employee.deptId = Convert.ToInt32(Console.ReadLine());

                    context.Employees.Add(employee);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }