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); } }
public IActionResult Change(SimulatorKey simulatorKey, bool value) { _simulatorDecider.ChangeSimulatorTo(simulatorKey, value); return RedirectToAction("Index"); }
public bool ShouldSimulate(SimulatorKey key) { var cookie = _context.HttpContext.Request.Cookies[key.ToString()]; return cookie != null && bool.Parse(cookie); }
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); }