public async Task<UserSetting> CreateSettingAsync(UserSetting setting) { if (await GetSettingAsync() != null) return null; UserSetting settingToCreate = Context.Settings.Add(setting); await SaveAsync(); return settingToCreate; }
public async Task<UserSetting> UpdateSettingAsync(UserSetting setting) { UserSetting settingToUpdate = await GetSettingAsync(); if (settingToUpdate == null) return await CreateSettingAsync(new UserSetting()); if (setting.HoursFormat != null) settingToUpdate.HoursFormat = setting.HoursFormat; if (setting.DateFormat != null) settingToUpdate.DateFormat = setting.DateFormat; if (setting.TimeZoneName != null) settingToUpdate.TimeZoneName = setting.TimeZoneName; if (setting.TimeZoneUtcOffset != null) settingToUpdate.TimeZoneUtcOffset = setting.TimeZoneUtcOffset; await SaveAsync(); return settingToUpdate; }