예제 #1
0
        public void SaveEmployeeDay(EmployeeDay employeeday)
        {
            if (employeeday == null)
            {
                throw new ArgumentNullException();
            }

            EmployeeDayStateRecording entity = GetEmployeesState(employeeday.EmployeeId, employeeday.Date);

            bool bNeedSave = EmployeeDayProcessor.IsNeedSave(employeeday);

            if (bNeedSave)
            {
                if (entity == null)
                {
                    entity = EmployeeDayProcessor.CreateRecordingEntity(employeeday);
                }
                else
                {
                    EmployeeDayProcessor.AssignToRecording(entity, employeeday);
                }

                SaveOrUpdate(entity);
                //employeeday.ID = entity.ID;
            }
            else
            {
                if (entity != null)
                {
                    DeleteByID(entity.ID);
                }
            }
        }
예제 #2
0
        public void CompareAndSave(EmployeeDay day)
        {
            if (day == null)
            {
                throw new ArgumentNullException();
            }


            SrvEmployeeRecordingDayList list = GetList(day.EmployeeId);

            if (list == null)
            {
                list = CreateDictionItem(day.EmployeeId);
            }

            EmployeeDayStateRecording entity = list[day.Date];

            if (entity == null)
            {
                if (day.IsValidDay)
                {
                    entity = EmployeeDayProcessor.CreateRecordingEntity(day);
                    UpdateEntity(entity);
                    list.AddEntity(entity);
                }
            }
            else
            {
                if (day.IsValidDay)
                {
                    if (!EmployeeDayProcessor.IsEqual(entity, day))
                    {
                        EmployeeDayProcessor.AssignToRecording(entity, day);
                        UpdateEntity(entity);
                    }
                }
                else
                {
                    DeleteEntity(entity);
                }
            }
        }