static public void CreateDeal(RequestContext request) { int userstate = UserHandler.AuthUser(request); if (userstate == 1 || userstate == 2) { TradeItem item = JsonConvert.DeserializeObject <TradeItem>(request.Message); User user = UserHandler.GetUserDataByToken(request); if (UserCardsHandler.CheckValidCardToUser(item.cardToTrade, user)) { try { TradingDatabaseHandler.CreateTradingDeal(user, item); Output.WriteConsole(Output.TradeCreationSuccess); } catch (Exception e) { Output.WriteConsole(e.Message); } return; } Output.WriteConsole(Output.TradeCreationInvalidCard); return; } Output.WriteConsole(Output.AuthError); }
static public void SellCard(RequestContext request) { int userstate = UserHandler.AuthUser(request); if (userstate == 1 || userstate == 2) { User user = UserHandler.GetUserDataByToken(request); string cardId = request.Message.Trim('"'); if (UserCardsHandler.CheckValidCardToUser(cardId, user)) { UserCardsHandler.SellCard(cardId, user); Output.WriteConsole(Output.CardSoldSuccess); return; } Output.WriteConsole(Output.CardSoldError); return; } Output.WriteConsole(Output.AuthError); }