Exemplo n.º 1
0
        private void Update(ApplicationWithHistory applicationWithHistory)
        {
            //update existing application
            _targetDatabase.UpdateSingle(applicationWithHistory.ApplicationWithSubVacancy.Application);

            //Insert new application history records
            foreach (var applicationHistory in applicationWithHistory.ApplicationHistory.Where(a => a.ApplicationHistoryId == 0))
            {
                _targetDatabase.Insert(applicationHistory);
            }

            //Update existing application history records
            foreach (var applicationHistory in applicationWithHistory.ApplicationHistory.Where(a => a.ApplicationHistoryId != 0))
            {
                _targetDatabase.UpdateSingle(applicationHistory);
            }

            var schoolAttended = applicationWithHistory.ApplicationWithSubVacancy.SchoolAttended;

            if (schoolAttended != null)
            {
                if (schoolAttended.SchoolAttendedId == 0)
                {
                    //Insert school attended if not already present
                    _targetDatabase.Insert(schoolAttended);
                }
                else
                {
                    //Otherwise update
                    _targetDatabase.UpdateSingle(schoolAttended);
                }
            }
        }
Exemplo n.º 2
0
        private void Create(ApplicationWithHistory applicationWithHistory)
        {
            //Insert existing application
            var applicationId = (int)_targetDatabase.Insert(applicationWithHistory.ApplicationWithSubVacancy.Application);

            //Insert new application history records
            foreach (var applicationHistory in applicationWithHistory.ApplicationHistory)
            {
                applicationHistory.ApplicationId = applicationId;
                _targetDatabase.Insert(applicationHistory);
            }

            var schoolAttended = applicationWithHistory.ApplicationWithSubVacancy.SchoolAttended;

            if (schoolAttended != null)
            {
                //Insert school attended
                schoolAttended.ApplicationId = applicationId;
                _targetDatabase.Insert(schoolAttended);
            }
        }