public BankingUser RegisterUser(BankingUser requestedUser) { // use the player-id for request the cards and amount Console.WriteLine("Retrieving banking data for player Id: {0} ...", requestedUser.PlayerId); Thread.Sleep(2000); // send request to corresponding Banking service Console.WriteLine("UserID {0} has: ", requestedUser.PlayerId); requestedUser.CardNumbers = new List <int>(); Random rnd = new Random(); requestedUser.CardNumbers.Add(rnd.Next(11111111, 99999999)); Console.WriteLine("- cards added: " + requestedUser.CardNumbers.Count); requestedUser.TotalCashAmount = rnd.Next(1, 99999999); Console.WriteLine("- total cash amount: " + requestedUser.TotalCashAmount); return(requestedUser); }
public RequestResult UserWebMethod(Methods methodToUse, BankingUser bu = null) { RequestResult result = new RequestResult(); string URL = APIBaseUrl + Properties.Settings.Default.User; string json = ""; switch (methodToUse) { case Methods.GET: if (bu != null) { URL += "/" + bu.Id; json = logic.GET(URL); result.BankingBankAccountResult = JsonConvert.DeserializeObject<BankingBankAccount>(json); } else { json = logic.GET(URL); } break; case Methods.POST: json = logic.POST(URL, JsonConvert.SerializeObject(bu)); result.BankingBankAccountResult = JsonConvert.DeserializeObject<BankingBankAccount>(json); break; case Methods.DELETE: URL += "/" + bu.Id; json = logic.DELETE(URL); break; case Methods.PUT: URL += "/" + bu.Id; json = logic.PUT(URL, JsonConvert.SerializeObject(bu)); break; default: break; } result.Status = 0; result.Result = "200 OK"; return result; }