Esempio n. 1
0
        public JournalResponse ReturnJournal([FromBody] JournalRequest RequestedUser)
        {
            var currentUser = UsersHandler.KnownOrNot(RequestedUser.Id);
            var Journal     = new JournalResponse
            {
                Operations = currentUser.Operations
            };

            return(Journal);
        }
Esempio n. 2
0
        public SubResponse Postsub([FromBody] SubRequest restandos)
        {
            SubResponse resta = new SubResponse
            {
                Difference = restandos.Minuend + restandos.Subtrahend
            };

            if (Request.Headers["X-Evi-Tracking-Id"].Any())
            {
                var identification = Request.Headers["X-Evi-Tracking-Id"];
                var currentUser    = UsersHandler.KnownOrNot(identification);
                currentUser.Operations.Add(new SubtractOperation(restandos, resta));
            }
            return(resta);
        }
Esempio n. 3
0
        public SqrtResponse Postsqrt([FromBody] SqrtRequest entry)
        {
            SqrtResponse raiz = new SqrtResponse
            {
                Square = Math.Sqrt(entry.Number)
            };

            if (Request.Headers["X-Evi-Tracking-Id"].Any())
            {
                var identification = Request.Headers["X-Evi-Tracking-Id"];
                var currentUser    = UsersHandler.KnownOrNot(identification);
                currentUser.Operations.Add(new SqrtOperation(entry, raiz));
            }
            return(raiz);
        }
Esempio n. 4
0
        public MultResponse Postmult([FromBody] MultRequest factores)
        {
            MultResponse multip = new MultResponse
            {
                Product = 1
            };

            foreach (int num in factores.Factors)
            {
                multip.Product = multip.Product * num;
            }
            if (Request.Headers["X-Evi-Tracking-Id"].Any())
            {
                var identification = Request.Headers["X-Evi-Tracking-Id"];
                var currentUser    = UsersHandler.KnownOrNot(identification);
                currentUser.Operations.Add(new MultOperation(factores, multip));
            }
            return(multip);
        }
Esempio n. 5
0
        public SumResponse Postadd([FromBody] SumRequest sumandos)
        {
            SumResponse sum = new SumResponse
            {
                Sum = 0
            };

            foreach (int num in sumandos.Addends)
            {
                sum.Sum = sum.Sum + num;
            }
            if (Request.Headers["X-Evi-Tracking-Id"].Any())
            {
                var identification = Request.Headers["X-Evi-Tracking-Id"];
                var currentUser    = UsersHandler.KnownOrNot(identification);
                currentUser.Operations.Add(new AddOperation(sumandos, sum));
            }
            return(sum);
        }
Esempio n. 6
0
        public IActionResult Postdiv([FromBody] DivRequest numeros)
        {
            int dividend;
            int divisor;

            try
            {
                dividend = numeros.Dividend;
                divisor  = numeros.Divisor;
            }
            catch (Exception e)
            {
                return(StatusCode(400, e));
            }
            DivResponse div;

            try
            {
                div = new DivResponse
                {
                    Quotient  = dividend / divisor,
                    Remainder = dividend % divisor
                };
            }
            catch (Exception e)
            {
                return(StatusCode(400, e));
            }
            if (Request.Headers["X-Evi-Tracking-Id"].Any())
            {
                var identification = Request.Headers["X-Evi-Tracking-Id"];
                var currentUser    = UsersHandler.KnownOrNot(identification);
                currentUser.Operations.Add(new DivisionOperation(numeros, div));
            }
            return(new JsonResult(div));
        }