public IActionResult Add(Person person) { if (person == null) { return(BadRequest()); } var data = _dataProvider.Get().ToList(); person.ID = data.Count() + 1; person.LastChange = DateTime.Now; data.Add(person); _dataProvider.Save(data); return(Ok()); }
/// <summary> /// Asynchronously saves data through the persistence layer. /// </summary> /// <param name="dataPersistence">The persistence layer used to execute the process</param> /// <param name="onSaveCompleted">Called when the saving process is completed with success</param> /// <param name="onSaveFailed">Called when the saving process failed</param> public static void SaveAppSettings( IDataPersistence dataPersistence, Action onSaveCompleted = null, Action onSaveFailed = null) { if (dataPersistence == null) { onSaveFailed?.Invoke(); Debug.LogWarning("DataPersistence cannot be null on persistence process."); return; } if (!AppSettings.Database.IsInitialized) { onSaveFailed?.Invoke(); Debug.LogWarning("Cannot save AppSettings. AppSettings is not initialized."); return; } var appSettingsData = AppSettings.Database.GetSerializableData(); dataPersistence.Save(m_AppSettingsDataPath, appSettingsData, onSaveCompleted, onSaveFailed); }