/// <summary> /// Count valid users /// </summary> /// <returns>Returns task with value</returns> public Task <HttpResponseMessage <IntResponse> > CountUsers() { //Creazione della response var response = new IntResponse { Value = GetUserReporitory().Count() }; //In tutti gli altri casi, confermo return(Task.FromResult(new HttpResponseMessage <IntResponse>( new HttpResponseMessage(HttpStatusCode.OK), response))); }
public static async Task <int> BlockNumber(string _chain, string _network, string _rpc = "") { WWWForm form = new WWWForm(); form.AddField("chain", _chain); form.AddField("network", _network); form.AddField("rpc", _rpc); string url = host + "/blockNumber"; UnityWebRequest webRequest = UnityWebRequest.Post(url, form); await webRequest.SendWebRequest(); IntResponse data = JsonUtility.FromJson <IntResponse>(System.Text.Encoding.UTF8.GetString(webRequest.downloadHandler.data)); return(data.response); }
public async static Task <int> CountLastPanics(string course, int seconds) { IntResponse res = await CallBackendAsync <IntResponse>("countlastpanics", new CountLastPanicsRequest(course, seconds)); // In case of an error keep the App working if (res == default(IntResponse)) { return(0); } if (!string.IsNullOrEmpty(res.ExceptionMessage)) { throw new Exception(res.ExceptionMessage); } return(res.Int); }
public ActionResult <IntResponse> Get(int ClientID, int ClientTransactionID) { try { Program.TraceLogger.LogMessage(methodName + " Get", ""); var result = Program.Simulator.EquatorialSystem; return(new IntResponse(ClientTransactionID, ClientID, methodName, (int)result)); } catch (Exception ex) { Program.TraceLogger.LogMessage(methodName + " Get", string.Format("Exception: {0}", ex.ToString())); var response = new IntResponse(ClientTransactionID, ClientID, methodName, 5); response.ErrorMessage = ex.Message; response.ErrorNumber = ex.HResult - Program.ASCOM_ERROR_NUMBER_OFFSET; return(response); } }
private bool AuctionItem(Item item, List <Client> clients, Auction auction, Database database) { bool isItemAuctionRunning = true; bool isStopInvoked = false; int clientId = 0; int currentBid = 0; int bidsInRow = 1; int highestBid = 0; Client previousBidder = null; Console.WriteLine("Starting an auction for item:\n\n"); DatabaseManager.DisplayItem(item); Console.WriteLine(); while (isItemAuctionRunning) { while (!Validator.ValidateMinMaxInt(clientId, 1, clients.LastOrDefault().Id) && isItemAuctionRunning) { Console.Write("Give ID of a person to place a bid ("); DisplayClientsIds(clients); Console.WriteLine("):"); IntResponse response = Validator.GetIntOrStop(); if (response.IsStopInvoked) { isStopInvoked = true; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nStop command has been invoked. The auction has been aborted.\n"); Console.ResetColor(); isItemAuctionRunning = false; } else { clientId = response.Result; } } Client currentBidder = clients.FirstOrDefault(c => c.Id == clientId); if (currentBidder != null) { Console.WriteLine("\n" + currentBidder.Name + " " + currentBidder.Surname + " is placing a bid. How much PLN?"); while (!Validator.ValidateMinMaxInt(currentBid, highestBid + 1) && isItemAuctionRunning) { Console.WriteLine("Bid must be higher than current highest bid - " + highestBid + " PLN."); IntResponse currentBidResult = Validator.PlaceBid(); if (currentBidResult.IsStopInvoked) { isStopInvoked = true; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nStop command has been invoked. The auction has been aborted.\n"); Console.ResetColor(); isItemAuctionRunning = false; } else { currentBid = currentBidResult.Result; } } if (isItemAuctionRunning) { highestBid = currentBid; Console.WriteLine("\n" + currentBidder.Name + " " + currentBidder.Surname + " succesfully placed a bid with " + currentBid + " PLN."); if (highestBid < item.MinPrice) { Console.WriteLine("\nCurrent highest bid is " + highestBid + " PLN. Minimal price (" + item.MinPrice + " PLN) not reached yet!"); } if (currentBidder == previousBidder) { bidsInRow++; } else { bidsInRow = 1; } if (bidsInRow >= 3 && currentBid > item.MinPrice) { SellItem(item, currentBidder, currentBid); auction.EligibleItems.Remove(item); DatabaseManager.SaveToFile(database); Console.ReadKey(); isItemAuctionRunning = false; } previousBidder = currentBidder; currentBid = 0; clientId = 0; } } else if (currentBidder == null && !isStopInvoked) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nThere is no eligible client with such id.\n"); Console.ResetColor(); clientId = 0; } } if (auction.EligibleItems.Count > 0) { Console.WriteLine("\nDo you want to proceed with the auction? Y/N\n"); return(Validator.YesNoValidator(Console.ReadLine())); } else { Console.WriteLine("\nNo eligible items left to auction.\nPress any key to continue..."); Console.ReadKey(); return(false); } }