public ServerActionResult Hello() { Authorization authorization = SessionController.GetSessionAuthorization(HttpContext); if (authorization == Authorization.Unauthorized) { return(new ServerActionResult(ServerActionResult.Status.Unauthorized)); } ServerResponse response = new ServerResponse(); Account sessionAccount = SessionController.GetSessionAccount(HttpContext); AccountController.GetAccountDetails(sessionAccount); if (authorization == Authorization.User) { (User user, ServerException exception) = AccountController.GetAccountUser(sessionAccount); response.InsertData(user.GetServerModel(), user); } else { (Admin admin, ServerException exception) = AccountController.GetAccountAdmin(sessionAccount); response.InsertData(admin.GetServerModel(), admin); } return(new ServerActionResult(ServerActionResult.Status.Ok, response)); }
public ServerActionResult RetrieveMatches() { ServerResponse response = new ServerResponse(); List <(Match, Team, Team)> matches = SportController.GetMatches(); foreach ((Match, Team, Team)match in matches) { response.InsertData(match.Item1.GetServerModel(), match.Item1); response.InsertData(match.Item2.GetServerModel(), match.Item2); response.InsertData(match.Item3.GetServerModel(), match.Item3); } return(new ServerActionResult(ServerActionResult.Status.Ok, response)); }
public ServerActionResult Login(Account login) { ServerResponse response = new ServerResponse(); (Actor actor, ServerException exception) = AccountController.Login(login); if (exception == ServerException.None) { SessionController.CreateSession(HttpContext, login, actor); response.InsertData(actor.GetServerModel(), actor); } else { response.Exception = exception; } return(new ServerActionResult(ServerActionResult.Status.Ok, response)); }
public ServerActionResult Register(Account register) { ServerResponse response = new ServerResponse(); (User user, ServerException exception) = AccountController.RegisterUser(register); if (exception == ServerException.None) { SessionController.CreateSession(HttpContext, register, user); response.InsertData(user.GetServerModel(), user); } else { response.Exception = exception; } return(new ServerActionResult(ServerActionResult.Status.Ok, response)); }