public void CompareAndSave(EmployeeDay day) { if (day == null) { throw new ArgumentNullException(); } EmployeePlanningDayList list = GetList(day.EmployeeId); if (list == null) { list = CreateDictionItem(day.EmployeeId); } EmployeeDayStatePlanning entity = list[day.Date]; if (entity == null) { if (day.IsValidDay) { entity = EmployeeDayProcessor.CreatePlanningEntity(day); UpdateEntity(entity); list.AddEntity(entity); } } else { if (day.IsValidDay) { if (!EmployeeDayProcessor.IsEqual(entity, day)) { EmployeeDayProcessor.AssignToPlanning(entity, day); UpdateEntity(entity); } } else { if (entity != null) { DeleteEntity(entity); } } } }
public void SaveEmployeeDay(EmployeeDay planningday) { if (planningday == null) { throw new ArgumentNullException(); } EmployeeDayStatePlanning entity = GetEmployeesState(planningday.EmployeeId, planningday.Date); bool bNeedSave = EmployeeDayProcessor.IsNeedSave(planningday); if (bNeedSave) { bool bModified = false; if (entity == null) { entity = EmployeeDayProcessor.CreatePlanningEntity(planningday); } else { if (!EmployeeDayProcessor.IsEqual(entity, planningday)) { EmployeeDayProcessor.AssignToPlanning(entity, planningday); bModified = true; } } if (entity.IsNew || bModified) { SaveOrUpdate(entity); } //planningday.ID = entity.ID; } else { if (entity != null) { DeleteByID(entity.ID); } } }