public void AssignShiftsToWorkDay(EmployeeProjectDbContext db, WorkDay workDay, Department department) { //an den yparxei h workDay sth vash tote thn dhmiourgw if (!db.WorkDays.Contains(workDay)) { CreateANewWorkDay(db, workDay); } foreach (var shift in workDay.Shifts) { shift.AssignEmployeesToShift(db, shift, department); } }
private void CreateANewWorkDay(EmployeeProjectDbContext db, WorkDay workDay) { try { if (workDay != null) { db.WorkDays.Add(workDay); db.SaveChanges(); } } catch (DataException e) { throw new DataException(e.Message); } }