public ActionResult <SvcResult> ResetPassword(User user) { using var service = new UserService(); var result = service.ResetPassword(user.username, user.email); if (result) { return(SvcResult.Get(0, "Success")); } else { return(SvcResult.Get(1, "Error")); } }
public ActionResult <SvcResult> RegisterEvent(GameEvent gameEvent) { var user = User.GetUser(); if (user == null) { return(new NotFoundResult()); } using var gameService = new GameService(); gameService.RegisterEvent(gameEvent); return(SvcResult.Get(0, "Success")); }
public ActionResult <SvcResult> DeleteGame(int gameId) { var user = User.GetUser(); if (user == null) { return(new NotFoundResult()); } using var gameService = new GameService(); var game = gameService.GetGame(gameId); gameService.DeleteGame(game); return(SvcResult.Get(0, "Success")); }
public ActionResult <SvcResult> SignUp(User user) { using var userService = new UserService(); using var authService = new AuthService(); if (userService.CheckEmailExist(user.email)) { return(SvcResult.Get(1, "Email in use")); } if (userService.CheckUsernameExist(user.username)) { return(SvcResult.Get(1, "User in use")); } return(!authService.SignUp(user) ? SvcResult.Get(1, "Error while adding user") : SvcResult.Get(0, "Success")); }
public ActionResult <SvcResult> ChangePassword(string oldPassword, string newPassword) { var user = User.GetUser(); if (user == null) { return(new NotFoundResult()); } using var userService = new UserService(); var result = userService.ChangePassword(oldPassword, newPassword); if (result) { return(SvcResult.Get(0, "Success")); } else { return(SvcResult.Get(1, "Error")); } }
public ActionResult <SvcResult> Authenticated() { return(SvcResult.Get(0, "Success")); }