public static NsgaLog GetLog(this TempDataDictionary tempData) { if (tempData.ContainsKey(LogKey)) { return(tempData.Peek(LogKey) as NsgaLog); } var log = new NsgaLog(); tempData[LogKey] = log; return(tempData.Peek(LogKey) as NsgaLog); }
public static SettingsViewModel GetSettings(this TempDataDictionary tempData) { if (tempData.ContainsKey(SettingsKey)) { return(tempData.Peek(SettingsKey) as SettingsViewModel); } var configurationProvider = new ConfigurationProvider(); var settingsViewModel = new SettingsViewModel { NsgaConfiguration = configurationProvider.GetConfiguration() }; tempData.SaveSettings(settingsViewModel); return(tempData.Peek(SettingsKey) as SettingsViewModel); }
public static List <PersonalData> GetPersonalDataList(this TempDataDictionary tempData) { if (!tempData.ContainsKey(PersonalDataListKey)) { tempData[PersonalDataListKey] = new List <PersonalData> { new PersonalData { Name = "Johny", Age = 25, Gender = Gender.M, Height = 185, Weight = 85, Pal = 1.5, Id = 0, }, new PersonalData { Name = "Anna", Age = 22, Gender = Gender.K, Height = 160, Weight = 50, Pal = 1.8, Id = 1 } }; } return(tempData.Peek(PersonalDataListKey) as List <PersonalData>); }
public static Uri GetSignUpUrl(ulong appId, IList <string> permissions, string redirectUri, TempDataDictionary tempData) { if (permissions == null) { throw new ArgumentNullException("permissions", "Value cannot be null."); } if (appId < 1) { throw new ArgumentOutOfRangeException("appId", "Value cannot be less than 1."); } if (redirectUri.IsNullOrEmpty()) { throw new ArgumentNullException("redirecturi", "Value cannot be Null or Empty."); } tempData[TempDataStringResuorce.FacebookStateData] = Guid.NewGuid().ToString("x"); var queryparameters = new Dictionary <string, object> { { "client_id", appId }, { "redirect_uri", redirectUri }, { "scope", permissions.ToString(',') }, { "state", CryptographyHelper.GetOneTimeHash(tempData.Peek(TempDataStringResuorce.FacebookStateData).ToString()) } }; var uribuilder = new UriBuilder { Scheme = "https", Host = "www.facebook.com", Path = "dialog/oauth", Query = queryparameters.ToUriQueryString(false) }; var result = uribuilder.Uri; return(result); }
public static IList <AlertModel> Alerts(this TempDataDictionary tempData, bool keep = false) { if (tempData == null) { throw new ArgumentNullException("tempData"); } var alerts = keep ? tempData.Peek(AlertKey) as IList <AlertModel> : tempData[AlertKey] as IList <AlertModel>; return(alerts); }
public void TempData_Peek_DoesNotMarkKeyForDeletion() { // Arrange var tempData = new TempDataDictionary(new DefaultHttpContext(), new NullTempDataProvider()); tempData["Bar"] = "barValue"; // Act var value = tempData.Peek("bar"); tempData.Save(); // Assert Assert.Equal("barValue", value); Assert.True(tempData.ContainsKey("Bar")); }
public static PersonalData GetPersonalData(this TempDataDictionary tempData) { if (!tempData.ContainsKey(PersonalDataKey)) { tempData[PersonalDataKey] = new PersonalData { Name = "Stefan", Age = 25, Gender = Gender.M, Height = 185, Weight = 85, Pal = 1.5 }; } return(tempData.Peek(PersonalDataKey) as PersonalData); }
public void PeekDoesNotMarkKeyAsRead() { // Arrange NullTempDataProvider provider = new NullTempDataProvider(); TempDataDictionary tempData = new TempDataDictionary(); Mock <ControllerContext> controllerContext = new Mock <ControllerContext>(); tempData["Bar"] = "barValue"; // Act object value = tempData.Peek("bar"); tempData.Save(controllerContext.Object, provider); // Assert Assert.Equal("barValue", value); Assert.True(tempData.ContainsKey("Bar")); }
public void PeekDoesNotMarkKeyAsRead() { // Arrange NullTempDataProvider provider = new NullTempDataProvider(); TempDataDictionary tempData = new TempDataDictionary(); Mock <ControllerContext> controllerContext = new Mock <ControllerContext>(); tempData["Bar"] = "barValue"; // Act object value = tempData.Peek("bar"); tempData.Save(controllerContext.Object, provider); // Assert Assert.AreEqual("barValue", value, "Incorrect value read from Peek()."); Assert.IsTrue(tempData.ContainsKey("Bar"), "Peek() shouldn't have removed 'Bar' from TempData."); }
public void TempData_Peek_DoesNotMarkKeyForDeletion() { // Arrange var tempData = new TempDataDictionary(GetHttpContextAccessor(), new NullTempDataProvider()); tempData["Bar"] = "barValue"; // Act var value = tempData.Peek("bar"); tempData.Save(); // Assert Assert.Equal("barValue", value); Assert.True(tempData.ContainsKey("Bar")); }
public void PeekDoesNotMarkKeyAsRead() { // Arrange NullTempDataProvider provider = new NullTempDataProvider(); TempDataDictionary tempData = new TempDataDictionary(); Mock<ControllerContext> controllerContext = new Mock<ControllerContext>(); tempData["Bar"] = "barValue"; // Act object value = tempData.Peek("bar"); tempData.Save(controllerContext.Object, provider); // Assert Assert.AreEqual("barValue", value, "Incorrect value read from Peek()."); Assert.IsTrue(tempData.ContainsKey("Bar"), "Peek() shouldn't have removed 'Bar' from TempData."); }
public void PeekDoesNotMarkKeyAsRead() { // Arrange NullTempDataProvider provider = new NullTempDataProvider(); TempDataDictionary tempData = new TempDataDictionary(); Mock<ControllerContext> controllerContext = new Mock<ControllerContext>(); tempData["Bar"] = "barValue"; // Act object value = tempData.Peek("bar"); tempData.Save(controllerContext.Object, provider); // Assert Assert.Equal("barValue", value); Assert.True(tempData.ContainsKey("Bar")); }
public static DailyDietsResultViewModel GetDailyDietsResultViewModel(this TempDataDictionary tempData) { return(tempData.ContainsKey(DailyDietsResultViewModeltKey) ? tempData.Peek(DailyDietsResultViewModeltKey) as DailyDietsResultViewModel : null); }
public static WeightsModel GetPreferencePointModel(this TempDataDictionary tempData, int personId) { return(tempData.ContainsKey(PrefPointKey + personId) ? tempData.Peek(PrefPointKey + personId) as WeightsModel : new WeightsModel()); }
public static AhpModel GetAhpModel(this TempDataDictionary tempData, int personId) { return(tempData.ContainsKey(AhpKey + personId) ? tempData.Peek(AhpKey + personId) as AhpModel : new AhpModel()); }
public static GroupDietsResultViewModel GetGroupDietsResultViewModel(this TempDataDictionary tempData) { return(tempData.ContainsKey(GroupDietsResultViewModeltKey) ? tempData.Peek(GroupDietsResultViewModeltKey) as GroupDietsResultViewModel : null); }
public static NsgaResult GetNsgaResult(this TempDataDictionary tempData) { return(tempData.ContainsKey(NsgaResultKey) ? tempData.Peek(NsgaResultKey) as NsgaResult : null); }
public static PreferencesViewModel GetPreferencesViewModel(this TempDataDictionary tempData, int personId) { return(tempData.ContainsKey(PreferencesKey + personId) ? tempData.Peek(PreferencesKey + personId) as PreferencesViewModel : InitializePreferencesViewModel()); }
public static PreferencesViewModel GetPreferencesViewModel(this TempDataDictionary tempData) { return(tempData.ContainsKey(PreferencesKey) ? tempData.Peek(PreferencesKey) as PreferencesViewModel : null); }