Esempio n. 1
0
        static void Main(string[] args)
        {
            DeleteEmployee(1089); // does not delete any employee because no such ID
            UpdateEmployee(23, "JobTitle", "Production Control Manager");
            // UpdateEmployee(23, "HireDate", "12.12.2015"); // throws ArgumentException because DateTime is expected

            Employee employeeToInsert = new Employee();
            employeeToInsert.FirstName = "Pesho";
            employeeToInsert.LastName = "Peshev";
            employeeToInsert.HireDate = DateTime.Now;
            employeeToInsert.JobTitle = "ASP.NET Developer";
            employeeToInsert.ManagerID = 45;
            employeeToInsert.MiddleName = "Mishev";
            employeeToInsert.Salary = 2345.80m;
            employeeToInsert.AddressID = 3;
            employeeToInsert.DepartmentID = 4;

            int newEmployeeId = InsertEmployee(employeeToInsert);
            Console.WriteLine("Employee with ID = {0} added.", newEmployeeId);
        }
Esempio n. 2
0
 public static int InsertEmployee(Employee employee)
 {
     softuniDbContext.Employees.Add(employee);
     softuniDbContext.SaveChanges();
     return employee.EmployeeID;
 }