예제 #1
0
        public Ventas CreateVenta(ConcretarVentaDto ventas)
        {
            var carrito = new Carrito
            {
                clienteId = Int32.Parse(ventas.clienteId),
            };

            _repository.Add <Carrito>(carrito);

            var venta = new Ventas
            {
                carritoId = carrito.carritoId,
                fecha     = DateTime.Now
            };

            _repository.Add <Ventas>(venta);

            foreach (string productoId in ventas.ListaProductos)
            {
                var cp = new Carrito_Producto
                {
                    carritoId  = carrito.carritoId,
                    productoId = Int32.Parse(productoId)
                };
                _repository.Add <Carrito_Producto>(cp);
            }

            return(venta);
        }
예제 #2
0
 public IActionResult Post(ConcretarVentaDto ventas) //que reciba un list de productos
 {
     try
     {
         return(new JsonResult(_service.CreateVenta(ventas))
         {
             StatusCode = 201
         });
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }