Exemplo n.º 1
0
 public static void setTestWorker()
 {
     using (var db = new EmploeeContext())
     {
         var emp = db.employees.Where(x => x.Position == "tester");
         if (!emp.Any())
         {
             var actualMaxIdnumber = db.employees.DefaultIfEmpty().Max(x => x.EmployeeId);
             var testEmp           = new Employee {
                 EmployeeId = actualMaxIdnumber + 1, FirstName = "Jan", LastName = "Kowalski", Address = "Warszawa", Email = "*****@*****.**", PhoneNumber = 725321843, Position = "tester"
             };
             db.employees.Add(testEmp);
             db.SaveChanges();
         }
     }
 }
Exemplo n.º 2
0
 public static void setTestTime()
 {
     using (var db = new EmploeeContext())
     {
         var wt = db.workTimes.Where(x => x.WorkTimeId == 123);
         if (!wt.Any())
         {
             DateTime begin    = new DateTime(2020, 5, 10, 4, 0, 0);
             DateTime end      = new DateTime(2020, 5, 10, 12, 0, 0);
             double   hourSpan = (end - begin).TotalHours;
             var      workT    = new WorkTime {
                 WorkTimeId = 123, BeginningTime = begin, EndTime = end, EmployeeId = 1, Hours = hourSpan
             };
             db.workTimes.Add(workT);
             db.SaveChanges();
         }
     }
 }