public IEmployeeContract CreateEmployee(string firstName, string lastName, string middleName, DateTime birthDate)
 {
     using (EmploymentContext ctx = new EmploymentContext())
     {
         Employee emp = new Employee()
         {
             FirstName  = firstName,
             LastName   = lastName,
             MiddleName = middleName,
             BirthDate  = birthDate
         };
         ctx.Employees.Add(emp);
         int numObjectsSaved = ctx.SaveChanges();
         if (numObjectsSaved == 1)
         {
             return(new EmployeeContract(emp));
         }
     }
     return(null);
 }
예제 #2
0
 public IndexModel(EmploymentContext context)
 {
     _context = context;
 }