public SettingsDTO GetSettings(string username) { var acc = accountService.GetAccountForUser(username); if (acc == null) { throw new Exception("Such account doesn't exist!"); } var settings = settingsRepository.GetById(acc.SettingsId); return(SettingsConverter.ToDTO(settings)); }
// // GET: /Settings/Delete/5 public ActionResult Delete(int id) { IRepository <Models.Settings> repo = new SettingsRepository(); repo.Delete(repo.GetById(id)); return(RedirectToAction("Index")); }
public void SimpeDeHydrate_Settings() { var settings = Create(); var settingsRepository = new SettingsRepository(ContextConnection()); var id = settingsRepository.Save(settings); var owner = settingsRepository.GetById(id); Assert.IsNotNull(owner); Assert.AreEqual(owner.Id, settings.Id); }
public void Simple_Status_Settings() { var settingsRepository = new SettingsRepository(ContextConnection()); var settings = Create(); settingsRepository.Save(settings); settingsRepository.SetInactive(settings); var inactive = settingsRepository.GetById(settings.Id); Assert.That(inactive.Status == EntityStatus.Inactive); settingsRepository.SetActive(settings); var active = settingsRepository.GetById(settings.Id); Assert.That(active.Status == EntityStatus.Active); settingsRepository.SetAsDeleted(settings); var deleted = settingsRepository.GetById(settings.Id); Assert.That(deleted.Status == EntityStatus.Deleted); }
public void ConstructSetsDefaultValuesForNonExistingFile() { // Arrange // Act ISettingsRepository repo = new SettingsRepository("non.existing.file"); // Assert foreach (var kvp in SettingKeys.DefaultValues) { Assert.AreEqual(kvp.Value, repo.GetById(kvp.Key).Value); } }
public void ConstructReadsValueForExistingFile() { // Arrange string fileName = GetTempFileName(); var sb = new StringBuilder(); foreach (var kvp in SettingKeys.DefaultValues) { sb.AppendLine($"{kvp.Key}={kvp.Key}"); } File.WriteAllText(fileName, sb.ToString()); // Act ISettingsRepository repo = new SettingsRepository(fileName); // Assert foreach (var kvp in SettingKeys.DefaultValues) { Assert.AreEqual(kvp.Key, repo.GetById(kvp.Key).Value); } }
public Account GetAccountForUser(string username) { var accountId = userService.GetEntityByUsername(username).AccountId; if (accountId == null) { return(null); } var account = repository.GetById(accountId.Value); if (account.SettingsId > 0) { account.Settings = settingsRepository.GetById(account.SettingsId); } if (account.PlanId > 0) { account.Plan = planRepository.GetById(account.PlanId); } var cards = virtualCardRepository.GetByAccountId(account.Id); if (cards != null && cards.Count > 0) { account.VirtualCards = cards; } var th = transactionsRepository.GetByAccountId(account.Id); if (th != null && th.Count > 0) { account.Transactions = th; } return(account); }
protected override void OnStartup( StartupEventArgs e ) { Instance = new SingleInstance( this ); if( !Instance.IsFirstInstance ) { Instance.Shutdown(); return; } DispatcherUnhandledException += App_DispatcherUnhandledException; Settings = new SettingsRepository(); bool minimize = false; if( Settings.GetById( SettingKeys.StartMinimized ).Get<bool>() ) { if( e.Args.Any( x => x.Equals( Constants.AutostartArgument, System.StringComparison.OrdinalIgnoreCase ) ) ) { minimize = true; } } if( !minimize ) { SplashScreen splash = new SplashScreen( "Resources\\Splash.png" ); splash.Show( true, true ); } TrayIcon = (TrayIcon)FindResource( "NotificationIcon" ); base.OnStartup( e ); #if DEBUG LocalizeDictionary.Instance.MissingKeyEvent += ( s, args ) => { Debug.WriteLine( $"Error: Resource key not found: '{args.Key}'" ); }; #endif DispatcherHelper.Initialize(); SetupViewServices(); ApplySettings(); MainWindow window = new MainWindow(); MainWindow = window; if( minimize ) { window.WindowState = WindowState.Minimized; } else { window.Show(); Instance.RegisterWindow( MainWindow ); } }
// // GET: /Settings/Edit/5 public ActionResult Edit(int id) { IRepository <Models.Settings> repo = new SettingsRepository(); return(View(repo.GetById(id))); }
public Settings GetById(string id) { return(repo.GetById(id)); }
// // GET: /Settings/Details/5 public ActionResult Details(int id) { IRepository <Settings> repo = new SettingsRepository(); return(View(repo.GetById(id))); }