Ejemplo n.º 1
0
        public IActionResult GetDiscounts([FromBody] AuthorizedObject <dynamic> auth)
        {
            var client = _clientRepository.FindByName(auth.ClientName);

            //validate password
            if (client != null && _clientRepository.IsKeyClientValid(client.Id, auth.ClientKey))
            {
                return(Json(client.Discounts));
            }

            return(null);
        }
Ejemplo n.º 2
0
        public IActionResult UpdateInfo([FromBody] AuthorizedObject <List <ClientInfoFromShop> > item)
        {
            if (item == null)
            {
                return(Json(new { success = 0 }));
            }

            var client = _clientRepository.FindByName(item.ClientName);

            //validate password
            if (client != null && _clientRepository.IsKeyClientValid(client.Id, item.ClientKey))
            {
                client.Info = item.Object;
                return(Json(new { success = 1 }));
            }
            return(Json(new { success = 0 }));
        }
Ejemplo n.º 3
0
        public IActionResult PlaceOrders([FromBody] AuthorizedObject <Dictionary <int, int> > item)
        {
            var client = _clientRepository.FindByName(item.ClientName);

            //validate password
            if (client != null && _clientRepository.IsKeyClientValid(client.Id, item.ClientKey))
            {
                var results = new Dictionary <int, long>();
                foreach (var o in item.Object)
                {
                    long order_placed = _orderRepository.AddOrder(o.Key, client.Id, o.Value);
                    results.Add(o.Key, order_placed);
                }

                return(Json(results));
            }
            return(BadRequest());
        }