public async Task Logout() { LoggedIn?.Invoke(); if (CurrentUser != null) { CurrentUser = null; } if (userRank != null) { userRank = null; } }
public async Task InsertUser(WS_User user) { if (await CheckIfUserEmailIsTaken(user)) { throw new Exception("E-mail already in use"); } user.Oprettet = DateTime.Now; var rank = new WS_UserRank { Rank = await rankRepo._context.FindAsync <WS_Rank>(2), User = user }; await _repository.Insert(user); await userRankRepo.Update(rank); }
public async Task <bool> Login(string email, string Password) { bool loginSucces = false; if (CurrentUser == null && loginAttempts < 4) { CurrentUser = dbService.Repository._context.WS_User.Where(x => x.Email == email && x.Password == Password).Include(x => x.PostNr).FirstOrDefault(); if (CurrentUser != null) { loginSucces = true; userRank = dbService.Repository._context.WS_UserRank.Where(x => x.User == CurrentUser).Include(x => x.Rank).FirstOrDefault(); LoggedIn?.Invoke(); } loginAttempts++; } return(loginSucces); }