Exemple #1
0
        public string DivPost(DivRequest calc)
        {
            var headerRequest = this.Request.Headers;
            int id            = ServerCalc.getIdHeader(headerRequest);

            var response = server.ServerCalc.DividingCalculation(calc.Dividend, calc.Divisor);

            if (id != -1)
            {
                var fecha = DateTime.UtcNow;
                fecha.ToString("O");
                Query addquery = new Query(Operations.Div, $"{calc.Dividend}-{calc.Divisor}={response.Item1.Quotient}c-{response.Item1.Remainder}", fecha);
                ServerCalc.writeQuery(id, addquery);
            }

            return(JsonConvert.SerializeObject(response.Item1));
        }
Exemple #2
0
        public string MultPost(MultRequest calc)
        {
            var headerRequest = this.Request.Headers;
            int id            = ServerCalc.getIdHeader(headerRequest);

            MultResponse response = server.ServerCalc.MultiplyingCalculation(calc.Factors);

            if (id != -1)
            {
                var fecha = DateTime.UtcNow;
                fecha.ToString("O");
                Query addquery = new Query(Operations.Mult, string.Join("*", calc.Factors) + "=" + response.Product, fecha);
                ServerCalc.writeQuery(id, addquery);
            }

            return(JsonConvert.SerializeObject(response));
        }
Exemple #3
0
        public string SqrtPost(SqrtRequest calc)
        {
            var headerRequest = this.Request.Headers;
            int id            = ServerCalc.getIdHeader(headerRequest);

            SqrtResponse response = server.ServerCalc.SquareRooCalculation(calc.Number);

            if (id != -1)
            {
                var fecha = DateTime.UtcNow;
                fecha.ToString("O");
                Query addquery = new Query(Operations.Sqrt, $"√{calc.Number}={response.Square}", fecha);
                ServerCalc.writeQuery(id, addquery);
            }

            return(JsonConvert.SerializeObject(response));
        }
Exemple #4
0
        public string SubPost(SubRequest calc)
        {
            var headerRequest = this.Request.Headers;
            int id            = ServerCalc.getIdHeader(headerRequest);

            IEnumerable <SubResponse> someCollection = server.ServerCalc.SubtractingCalculation(calc.Minuend, calc.substrahend);
            var list = someCollection.Cast <SubResponse>().ToList();

            if (id != -1)
            {
                var fecha = DateTime.UtcNow;
                fecha.ToString("O");
                Query addquery = new Query(Operations.Sub, $"{calc.Minuend}-{calc.substrahend}={list[0].Difference}", fecha);
                ServerCalc.writeQuery(id, addquery);
            }

            return(JsonConvert.SerializeObject(list[0]));
        }
Exemple #5
0
        public string AddPost(AddRequest calc)
        {
            var headerRequest = this.Request.Headers;
            int id            = ServerCalc.getIdHeader(headerRequest);

            calc.Addens = server.ServerCalc.CleanArrayOfZeroValues(calc.Addens);

            AddResponse response = server.ServerCalc.AddingCalculation(calc.Addens);

            if (id != -1)
            {
                var fecha = DateTime.UtcNow;
                fecha.ToString("O");
                Query addquery = new Query(Operations.Add, string.Join("+", calc.Addens) + "=" + response.Sum, fecha);
                ServerCalc.writeQuery(id, addquery);
            }

            return(JsonConvert.SerializeObject(response, new Newtonsoft.Json.Converters.StringEnumConverter()));
        }