public ActionResult <UserSessionModel> Post([FromBody] UserInputModel userData) { var newUser = _createUserService.CreateUser(userData.Username, userData.Password); var newUserId = newUser.UserId.ToString(); var walletUserId = _createUserService.CreateWallet(newUserId); if (walletUserId != newUserId) { return(StatusCode(500, "Server Error")); } var userSession = _loginService.CreateSessionByUserId(newUserId); var mappedUserSession = _mapper.Map <UserSessionModel>(userSession); return(Ok(mappedUserSession)); }
public UserModel EditUser(UserInputModel userInput) { if (userInput.Id == null || userInput.Username == null && userInput.Password == null && userInput.ProfileImgUrl == null) { throw new InvalidInputException(_path, "Patch()"); } var user = new User { Id = userInput.Id, Username = userInput.Username, Password = userInput.Password, ProfileImgUrl = userInput.ProfileImgUrl }; return(new UserModel(_patchUser.Edit(user))); }
public UserAuthModel AddUser(UserInputModel userInput) { if (userInput.Username == null || userInput.Password == null) { throw new InvalidInputException(_path, "Get()"); } _addUser.CreateUser(userInput.Username, userInput.Password); var user = _getUserData.GetDataByUsername(userInput.Username); var userModel = new UserAuthModel { Id = user.Id, Username = user.Username, JwtToken = _generateJwtToken.NewUserToken(user) }; return(userModel); }
public SessionModel PostNewUser([FromBody] UserInputModel userInputModel) { var user = _createNewUserService.CreateNewUser( userInputModel.Username, userInputModel.Password ); var session = _createSessionService.CreateNewSession( user.Id ); var wallet = _createWalletService.InsertFirstDeposit( user.Id, user.Username ); return(new SessionModel { Id = session.Id, UserId = session.UserId, CreatedDate = session.CreatedDate }); }
[HttpPut] public IActionResult Put(UserInputModel input) => Ok(Manager.Update(input));
[HttpPost] public IActionResult Post(UserInputModel input) => Ok(Manager.Add(input));