Ejemplo n.º 1
0
        public async Task <IActionResult> MakeOrder(OrderPropertiesContainer order)
        {
            if (order.ShopId != null && order.WarehouseId != null &&
                (order.ShopId != null || order.WarehouseId != null))
            {
                return(StatusCode(401));
            }
            await _orderService.MakeOrderAsync(order);

            return(Ok(order));
        }
Ejemplo n.º 2
0
        public async Task MakeOrderAsync(OrderPropertiesContainer orderPropertiesContainer)
        {
            var commodities        = _commodityService.GetByIdCollection(orderPropertiesContainer.CommodityIds);
            var purchaseOrderModel = new PurchaseOrderModel
            {
                Commodities = commodities,
                Date        = DateTime.Now.Date,
                Name        = orderPropertiesContainer.Name,
                Number      = orderPropertiesContainer.Number,
                ShopId      = orderPropertiesContainer.ShopId,
                WarehouseId = orderPropertiesContainer.WarehouseId
            };
            var order = _mapper.Map <PurchaseOrder>(purchaseOrderModel);
            await _unit.PurchaseOrderRepository.CreateAsync(order);

            await _unit.Save();
        }