예제 #1
0
        public bool UpdateSysPreferences(SysPrefsModel updateSysPrefsModel)
        {
            bool updated = false;

            if (updateSysPrefsModel.SysPrefs.SysPrefsId > 0)
            {
                // it means that there was a record in the database.
                var recsUpdated = _SysPrefsRepo.Update(updateSysPrefsModel.SysPrefs);
                updated = (recsUpdated == 1);
            }
            else
            {
                // it means that there was a record in the database.
                var recIsUpdated = _SysPrefsRepo.Add(updateSysPrefsModel.SysPrefs) > 0;
                updated = recIsUpdated;
            }
            // run this update regardless
            if (updateSysPrefsModel.WooSettings.WooSettingsId > 0)
            {
                // it means that there was a record in the database.
                var recsUpdated = _WooSettingsRepo.Update(updateSysPrefsModel.WooSettings);
                updated = updated && (recsUpdated == 1);
            }
            else
            {
                // it means that there was a record in the database.
                var recIsUpdated = _WooSettingsRepo.Add(updateSysPrefsModel.WooSettings) > 0;
                updated = updated && recIsUpdated;
            }
            return(updated);
        }
예제 #2
0
        public async Task <bool> UpdateSysPreferencesAsync(SysPrefsModel updateSysPrefsModel)
        {
            bool updated     = false;
            int  recsUpdated = 0;

            if (updateSysPrefsModel.SysPrefs.SysPrefsId > 0)
            {
                // it means that there was a record in the database.
                recsUpdated = await _SysPrefsRepo.UpdateAsync(updateSysPrefsModel.SysPrefs);

                updated = (recsUpdated > 0);
            }
            else
            {
                // it means that there was a record in the database.
                recsUpdated = await _SysPrefsRepo.AddAsync(updateSysPrefsModel.SysPrefs);

                updated = recsUpdated > 0;
            }
            // run this update regardless
            if (updateSysPrefsModel.WooSettings.WooSettingsId > 0)
            {
                // it means that there was a record in the database.
                recsUpdated = await _WooSettingsRepo.UpdateAsync(updateSysPrefsModel.WooSettings);

                updated = updated && (recsUpdated > 0);
            }
            else
            {
                // it means that there was a record in the database.
                recsUpdated = await _WooSettingsRepo.AddAsync(updateSysPrefsModel.WooSettings);

                updated = updated && (recsUpdated > 0);
            }
            return(updated);
        }