public static List <SelectListItem> PopulateSessionSelectListItem() { try { SessionLogic sessionLogic = new SessionLogic(); List <SESSION> sessions = sessionLogic.GetActiveSessions(); if (sessions == null || sessions.Count <= 0) { return(new List <SelectListItem>()); } List <SelectListItem> selectItemList = new List <SelectListItem>(); SelectListItem list = new SelectListItem(); list.Value = ""; list.Text = SelectSession; selectItemList.Add(list); foreach (SESSION session in sessions) { SelectListItem selectList = new SelectListItem(); selectList.Value = session.Id.ToString(); selectList.Text = session.Name; selectItemList.Add(selectList); } return(selectItemList); } catch (Exception) { throw; } }
public WController(IWebHostEnvironment environment, IStringLocalizer localizer, FoxIDsSettings settings, SessionLogic sessionLogic) { this.environment = environment; this.localizer = localizer; this.settings = settings; this.sessionLogic = sessionLogic; }
public void ValidateLoginValidCredentials() { Admin admin = new Admin() { Email = "*****@*****.**", Password = "******", Name = "Sebastian Perez", Id = Guid.NewGuid() }; var sessionRepositoryMock = new Mock <ISessionRepository>(MockBehavior.Strict); var adminRepositoryMock = new Mock <IRepository <Admin> >(MockBehavior.Strict); adminRepositoryMock.Setup(m => m.GetByCondition( It.IsAny <Expression <Func <Admin, bool> > >())).Returns(admin); sessionRepositoryMock.Setup(m => m.Add(It.IsAny <Session>())); sessionRepositoryMock.Setup(m => m.ValidateSession(It.IsAny <Guid>())).Returns(false); sessionRepositoryMock.Setup(m => m.SaveChanges()); var sessionLogic = new SessionLogic(adminRepositoryMock.Object, sessionRepositoryMock.Object); var result = sessionLogic.ValidateLogin("*****@*****.**", "Pass"); sessionRepositoryMock.VerifyAll(); sessionRepositoryMock.VerifyAll(); Assert.AreEqual(admin, result); }
public void OnActionExecuting(ActionExecutingContext context) { string token = context.HttpContext.Request.Headers["Authorization"]; if (token == null) { context.Result = new ContentResult() { Content = "Token is required", }; } using (var sessions = new SessionLogic(new UserRepository(ContextFactory.GetNewContext()))) { if (!sessions.IsValidToken(token)) { context.Result = new ContentResult() { Content = "Invalid Token", }; } if (!sessions.HasLevel(token, _role)) { context.Result = new ContentResult() { Content = "The user isen't " + _role, }; } } }
//////////////// public ResetModeMod() { ResetModeMod.Instance = this; this.Session = new SessionLogic(); }
// To initiate the adventure private async void Start_Clicked(object sender, EventArgs e) { Start.IsEnabled = false; // disable the button to avoid multiple clicks. actIndicator.IsRunning = true; await App.isNetworkAccess(); if (adventure.waypointID == null) // handle error when no starting waypoint found { actIndicator.IsRunning = false; await DisplayAlert("Error", "Could not find the stating waypoint! This adventure is current unavailable or under development.", "Cancel"); Start.IsEnabled = true; // enable the button. return; } session = await SessionLogic.GetSession(App.myTeam.teamID, adventure.adventureID); if (session == null) //this is the first time the team is playing this adventure { await SessionLogic.PostSession(adventure); //create a new session for this adventure and team session = await SessionLogic.GetSession(App.myTeam.teamID, adventure.adventureID); } else { actIndicator.IsRunning = false; bool sng = await DisplayAlert("Warning", "Starting new game will cause your past save of this adventure be removed!", "Start new game", "Cancel"); if (sng == true) { actIndicator.IsRunning = true; //Reset game state await SessionLogic.PutSession(App.myTeam.teamID, adventure.adventureID, adventure.waypointID.Value); session = await SessionLogic.GetSession(App.myTeam.teamID, adventure.adventureID); } else { Start.IsEnabled = true; // enable the button. return; } } Waypoint wp = await WaypointLogic.GetWaypoint(session.WaypointID); App.atWaypointID = session.WaypointID; App.atAdventureID = session.AdventureID; App.reachableWaypoints = await AdventureMapLogic.GetAdventureMap(App.atWaypointID); App.getLocation(); actIndicator.IsRunning = false; Start.IsEnabled = true; // enable the button. await Navigation.PushAsync(new StoryPage(adventure.title, wp)); }
public LoginController(TelemetryScopedLogger logger, IStringLocalizer localizer, ITenantRepository tenantRepository, SessionLogic sessionLogic, SequenceLogic sequenceLogic, AccountLogic accountLogic, LoginUpLogic loginUpLogic, LogoutUpLogic logoutUpLogic) : base(logger) { this.logger = logger; this.localizer = localizer; this.tenantRepository = tenantRepository; this.sessionLogic = sessionLogic; this.sequenceLogic = sequenceLogic; this.accountLogic = accountLogic; this.loginUpLogic = loginUpLogic; this.logoutUpLogic = logoutUpLogic; }
public void Initialize() { this.options = new DbContextOptionsBuilder <BetterCalmContext>().UseInMemoryDatabase(databaseName: "MSP.BetterCalmDB").Options; this.context = new BetterCalmContext(this.options); this.adminRepository = new AdministratorRepository(this.context); this.sessionLogic = new SessionLogic(this.adminRepository); Administrator admin1 = new Administrator("Mauro", "*****@*****.**", "12345"); Administrator admin2 = new Administrator("Rodrigo", "*****@*****.**", "4567"); adminRepository.Add(admin1); adminRepository.Add(admin2); }
public MainWindow() { InitializeComponent(); DataContext = this; var bindings = new Bindings(); LoadKernel(bindings); _session = new Session.Session(); _sessionLogic = new SessionLogic(_dbConn); flagHandler = new ObservableHandler <IDbConn>(_dbConn); flagHandler.Add("HasDummyRan", OnDbConnHasDummyRanChanged); }
public void SessionLogic_CreateSession() { // Arrange State.Sessions.Clear(); var sessionLogic = new SessionLogic(); // Act var session = sessionLogic.CreateSession(); // Assert Assert.AreEqual(session.Rank, RankEnum.Beginner); Assert.AreEqual(session.Level, 1); Assert.AreEqual(State.Sessions.Count, 1); }
public void SessionLogic_EndSession() { // Arrange State.Sessions.Clear(); var sessionLogic = new SessionLogic(); var session = sessionLogic.CreateSession(); Assert.AreEqual(State.Sessions.Count, 1); // Act sessionLogic.EndSession(session); // Assert Assert.AreEqual(State.Sessions.Count, 0); }
public void ValidateLoginWrongCredentials() { var sessionRepositoryMock = new Mock <ISessionRepository>(MockBehavior.Strict); var adminRepositoryMock = new Mock <IRepository <Admin> >(MockBehavior.Strict); adminRepositoryMock.Setup(m => m.GetByCondition( It.IsAny <Expression <Func <Admin, bool> > >())).Returns((Admin)null); var sessionLogic = new SessionLogic(adminRepositoryMock.Object, sessionRepositoryMock.Object); var result = sessionLogic.ValidateLogin("*****@*****.**", "password"); sessionRepositoryMock.VerifyAll(); sessionRepositoryMock.VerifyAll(); Assert.IsNull(result); }
protected async override void OnAppearing() { base.OnAppearing(); await App.isNetworkAccess(); session = SessionLogic.GetSession(App.myTeam.teamID, adventure.adventureID).Result; if (session == null) //this is the first time the team is playing this adventure { Continue.IsVisible = false; Grid.SetColumnSpan(Start, 2); } else { Continue.IsVisible = true; } }
private void VerifyToken(Guid token, ActionExecutingContext context) { // Usamos using asi nos aseguramos que se llame el Dispose de este `sessions` enseguida salgamos del bloque using (var sessions = new SessionLogic(null, null)) { // Verificamos que el token sea valido if (!sessions.IsValidToken(token)) { context.Result = new ContentResult() { Content = "Debe iniciar sesión para acceder", }; } // Verificamos que el rol del usuario sea correcto if (!sessions.HasLevel(token, role)) { context.Result = new ContentResult() { Content = "No tiene permiso para acceder", }; } } }
public static List <SESSION> GetAllSessions() { try { SessionLogic sessionLogic = new SessionLogic(); List <SESSION> sessions = sessionLogic.GetAll(); if (sessions != null && sessions.Count > 0) { sessions.Insert(0, new SESSION() { Id = 0, Name = SelectSession }); } return(sessions); } catch (Exception) { throw; } }
public SessionController() { logic = new SessionLogic(new SqlSessionContext("Server=localhost;Database=dungeon_survivor;Uid=root;Pwd=test;")); }
// To support movement between waypoint, it will check whether the players are allowed to move to the next waypoint or not async void OnWaypointAlertClick(object sender, EventArgs e) { continue_btn.IsEnabled = false; // disable the button to avoid multiple clicks. actIndicator.IsRunning = true; await App.isNetworkAccess(); if (isCompleted == false) // requests to finished challenge before move to the next waypoint { actIndicator.IsRunning = false; await DisplayAlert("Failed", "You have not completed the challenge yet. Try again!", "Ok"); continue_btn.IsEnabled = true; // enable the button. return; } if (isEndpoint == true) // handles the last waypoint completed. { actIndicator.IsRunning = false; await DisplayAlert("Congratulation", "You have completed '" + adventureTitle + "'!", "Ok"); continue_btn.Text = "Completed"; continue_btn.IsEnabled = false; return; } await App.getLocation(); // the main method to compare location Waypoint wp = await WaypointLogic.GetWaypoint(App.atWaypointID); bool reached = false; foreach (Waypoint w in App.reachableWaypoints) { if (w.WaypointId == wp.WaypointId) { reached = true; } } if (reached == false) // alerts if not reached a new waypoint yet { actIndicator.IsRunning = false; await DisplayAlert("Failed", "You have not reached a new story point yet. Keep searching!", "Ok"); continue_btn.IsEnabled = true; // enable the button. return; } //Save new state await SessionLogic.PutSession(App.myTeam.teamID, App.atAdventureID, App.atWaypointID); // opens new Story page with the content of the next waypoint App.reachableWaypoints = await AdventureMapLogic.GetAdventureMap(App.atWaypointID); actIndicator.IsRunning = false; continue_btn.IsEnabled = true; // enable the button. await Navigation.PushAsync(new StoryPage(adventureTitle, wp)); }
public SessionTest() { logic = new SessionLogic(new MemorySessionContext()); }