public void StoreStatusOf(SimulatorKey key, string ipAddress, bool isEnabled)
 {
     if (isEnabled)
     {
         _simulatorsStatus.Add(new SimulatorStatus { IpAddress = ipAddress, Key = key });
     }
     else
     {
         _simulatorsStatus.RemoveAll(x => x.IpAddress == ipAddress && x.Key == key);
     }
 }
Esempio n. 2
0
 public IActionResult Change(SimulatorKey simulatorKey, bool value)
 {
     _simulatorDecider.ChangeSimulatorTo(simulatorKey, value);
     return RedirectToAction("Index");
 }
Esempio n. 3
0
 public bool ShouldSimulate(SimulatorKey key)
 {
     var cookie = _context.HttpContext.Request.Cookies[key.ToString()];
     return cookie != null && bool.Parse(cookie);
 }
Esempio n. 4
0
 public void ChangeSimulatorTo(SimulatorKey key, bool value)
 {
     _context.HttpContext.Response.Cookies.Append(key.ToString(), value.ToString(), new CookieOptions { Expires = DateTimeOffset.MaxValue });
 }
 public bool StatusFor(SimulatorKey key, string ipAddress)
 {
     return _simulatorsStatus.Any(x => x.IpAddress == ipAddress && x.Key == key);
 }
 public bool ShouldSimulate(SimulatorKey key)
 {
     return _simulatorStatusStorage.StatusFor(key, _httpContext.CurrentIpAddress());
 }
 public void ChangeSimulatorTo(SimulatorKey key, bool isEnabled)
 {
     _simulatorStatusStorage.StoreStatusOf(key, _httpContext.CurrentIpAddress(), isEnabled);
 }