public void Div(string trackingId) { #region DivisionStuff Console.WriteLine("-------Division Operation------"); Console.WriteLine("Type the integer division you want to do(ex:1243 / 12 / 2): "); char symb = '/'; string div = Console.ReadLine(); div = CheckingSymbol.HaveOperationSymbol(symb, div); int[] numbers; if (ParsingComprobation.CanBeParsed(symb, div)) { numbers = ParsingComprobation.Parse(ParsingComprobation.SeparateString(symb, div)); } else { return; } #endregion #region Connection DivRequest division = new DivRequest(); DivResponse result = new DivResponse(); division.Numbers = numbers; HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"{url}div"); request.Method = "POST"; request.ContentType = "application/json"; if (trackingId != "") { request.Headers.Add("X_Evi_Tracking_Id", trackingId); } using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream())) { var jason = JsonConvert.SerializeObject(division); dataStream.Write(jason); dataStream.Close(); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader stRead = new StreamReader(response.GetResponseStream())) { Console.WriteLine("The server operation's result is:"); result = JsonConvert.DeserializeObject <DivResponse>(stRead.ReadToEnd()); Console.WriteLine(result.Quotient); Console.WriteLine("The remainder of the last division is:"); Console.WriteLine(result.Remainder); stRead.Close(); } #endregion }
public void Subt(string trackingId) { #region SubtractionStuff Console.WriteLine("------Subtraction Operation------"); Console.WriteLine("Type the integer subtraction you want to do(ex:13 - 12 - 5): "); char symb = '-'; string subt = Console.ReadLine(); subt = CheckingSymbol.HaveOperationSymbol(symb, subt); int[] numbers; if (ParsingComprobation.CanBeParsed(symb, subt)) { numbers = ParsingComprobation.Parse(ParsingComprobation.SeparateString(symb, subt)); } else { return; } #endregion #region Connection SubtractRequest subtract = new SubtractRequest(); SubtractResponse result = new SubtractResponse(); subtract.Numbers = numbers; HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"{url}sub"); request.Method = "POST"; request.ContentType = "application/json"; if (trackingId != "") { request.Headers.Add("X_Evi_Tracking_Id", trackingId); } using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream())) { var jason = JsonConvert.SerializeObject(subtract); dataStream.Write(jason); dataStream.Close(); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader stRead = new StreamReader(response.GetResponseStream())) { Console.WriteLine("The server operation's result is:"); result = JsonConvert.DeserializeObject <SubtractResponse>(stRead.ReadToEnd()); Console.WriteLine(result.Result); stRead.Close(); } #endregion }
public void Mult(string trackingId) { #region MultiplicationStuff Console.WriteLine("------Multplication Operation------"); Console.WriteLine("Type the integer multiplication you want to do, multipliers must have 10 or less digits(ex:13 * 12 * 5): "); char symb = '*'; string mult = Console.ReadLine(); mult = CheckingSymbol.HaveOperationSymbol(symb, mult); int[] numbers; if (ParsingComprobation.CanBeParsed(symb, mult, true)) { numbers = ParsingComprobation.Parse(ParsingComprobation.SeparateString(symb, mult)); } else { return; } #endregion #region Connection MultRequest multiply = new MultRequest(); MultResponse result = new MultResponse(); multiply.Multipliers = numbers; HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"{url}mult"); request.Method = "POST"; request.ContentType = "application/json"; if (trackingId != "") { request.Headers.Add("X_Evi_Tracking_Id", trackingId); } using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream())) { var jason = JsonConvert.SerializeObject(multiply); dataStream.Write(jason); dataStream.Close(); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader stRead = new StreamReader(response.GetResponseStream())) { Console.WriteLine("The server operation's result is:"); result = JsonConvert.DeserializeObject <MultResponse>(stRead.ReadToEnd()); Console.WriteLine(result.Result); stRead.Close(); } #endregion }