public Result<Option> SetFirstTimeOption() { return Result<Option>.SafeExecute<IOptionService>(result => { using (DataContext = new RmmDataContext(RmmDataContext.CONNECTIONSTRING)) { var newFirstTimeOption = new Option() { id = 1, IsPrimaryTile = false, IsPassword = false, IsSynchro = false, Favorite = 0, LastBackupVersion = 0, ModifiedDate = DateTime.Now, RefreshTimeBackup = DateTime.Now }; DataContext.Option.Log().InsertOnSubmit(newFirstTimeOption); DataContext.SubmitChanges(); result.Value = newFirstTimeOption; } }, () => "erreur"); }
public Result<Option> UpdateOption(Option optionToUpdate) { return Result<Option>.SafeExecute<IOptionService>(result => { using (DataContext = new RmmDataContext(RmmDataContext.CONNECTIONSTRING)) { var entityToUpdate = DataContext.Option.Log().First(); entityToUpdate.IsPassword = optionToUpdate.IsPassword; entityToUpdate.IsPrimaryTile = optionToUpdate.IsPrimaryTile; entityToUpdate.IsSynchro = optionToUpdate.IsSynchro; entityToUpdate.Favorite = optionToUpdate.Favorite; entityToUpdate.ModifiedDate = DateTime.Now; entityToUpdate.RefreshTimeBackup = optionToUpdate.RefreshTimeBackup; DataContext.SubmitChanges(); result.Value = entityToUpdate; } }, () => "erreur"); }