示例#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);
                }
            }
        }
        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);
                }
            }
        }