public void CanUpdate() { SettingsRepository repo = new SettingsRepository(); var admins = repo.GetAllAdminLevels(); var al = admins[0]; al.DisplayName = "update"; repo.Save(al, 26); var updated = repo.GetAllAdminLevels(); Assert.AreEqual(al.DisplayName, updated[0].DisplayName); }
private void btnSave_Click_1(object sender, EventArgs e) { if (!model.IsValid()) { MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle); return; } SettingsRepository r = new SettingsRepository(); var adminLevels = r.GetAllAdminLevels(); if (model.Id <= 0 && adminLevels.FirstOrDefault(a => a.DisplayName == model.DisplayName.Trim()) != null) { MessageBox.Show(Translations.AdminLevelNameUnique, Translations.ValidationErrorTitle); return; } bsAdminLevel.EndEdit(); int userid = ApplicationData.Instance.GetUserId(); r.Save(model, userid); // Show the warning message if this is not the start up wizard if (!IsStartUp) MessageBox.Show(Translations.AddAdminLevelNoAdminUnits, Translations.AdminLevelType); OnSave(); this.Close(); }