public double GetProgressByModule(string userId, GameLevelType module) { UserProgressDTO userProgress = new UserProgressDTO() { UserId = userId, Module = module }; return(_userService.GetProgressByModule(userProgress)); }
public void InsertUserProgress(UserProgressDTO userProgress) { UserProgress user = new UserProgress() { UserId = userProgress.UserId, Module = userProgress.Module, Progress = 0 }; _mongoRepository.InsertOne(user); }
public double GetProgressByModule(UserProgressDTO userProgress) { var user = _mongoRepository.FindOne(user => user.UserId == userProgress.UserId && user.Module == userProgress.Module); if (user is null) { InsertUserProgress(userProgress); user = _mongoRepository.FindOne(userSelected => userSelected.UserId == userProgress.UserId && userSelected.Module == userProgress.Module); } return(user.Progress / 100); }
public async Task <IActionResult> RegisterLogin([FromBody] AuthenticateUserDTO userDTO) { var email = string.IsNullOrEmpty(userDTO.Email); var password = string.IsNullOrEmpty(userDTO.Password); var name = string.IsNullOrEmpty(userDTO.Name); if (email || password || name) { return(Unauthorized(new { ReturnStatusCode.NotAuthorized, Message = "Usuário, senha ou nome vazio", IsSignuped = false })); } if (userDTO.Password != userDTO.RepeatPassword) { return(Unauthorized(new { ReturnStatusCode.NotAuthorized, Message = "Senhas não indenticas", IsSignuped = false })); } await _userService.AddUser(userDTO); AddParamsToJWT(); var validUser = await _userService.GetUserByLogin(userDTO); var levels = Enum.GetValues(typeof(GameLevelType)); foreach (GameLevelType level in levels) { var userProgress = new UserProgressDTO { UserId = validUser.Id, Module = level }; _userService.InsertUserProgress(userProgress); } var tokenString = _authService.BuildJWTToken(tokenParams); return(Ok(new { StatusCode = ReturnStatusCode.Ok, Message = "Cadastrado com sucesso", Token = tokenString, IsSignuped = true, validUser.Id, UserName = validUser.Name })); }
public double GetProgressByModule(UserProgressDTO userProgress) { return(_userProgressRepository.GetProgressByModule(userProgress)); }
public void InsertUserProgress(UserProgressDTO userProgress) { _userProgressRepository.InsertUserProgress(userProgress); }