// GET http://localhost:8005/api/sync/product-stock/{serialNo}/{productId}
        public IHttpActionResult GetInventoryStockForProduct(string serialNo, int productId, int warehouseId)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            var result = new InventoryStockSync();

            var inventoryStock = ProductServices.GetInventoryStocksByProductAndTenantLocation(productId, warehouseId);

            result = AutoMapper.Mapper.Map(inventoryStock, result);
            if (result != null)
            {
                result.LocationDetails = _commonDbServices.LocationsByProductDetails(productId, warehouseId);

                result.Count = result.LocationDetails.ProductDetails.Count;

                result.TerminalLogId = TerminalServices
                                       .CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, 1, terminal.TerminalId,
                                                          TerminalLogTypeEnum.InventoryStockSync).TerminalLogId;

                return(Ok(result));
            }
            return(BadRequest("No stock information available for the requested product in the warehouse."));
        }
        // GET http://localhost:8005/api/sync/inventorystocks/{reqDate}/{serialNo}
        // GET http://localhost:8005/api/sync/inventorystocks/2014-11-23/920013c000814
        public IHttpActionResult GetInventorystocks(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            var result = new InventoryStockSyncCollection();

            var allInventoryStocks = ProductServices.GetAllInventoryStocks(terminal.TenantId, terminal.WarehouseId, reqDate);

            var inventoryStocks = new List <InventoryStockSync>();

            foreach (var p in allInventoryStocks)
            {
                var inventory = new InventoryStockSync();
                var mapped    = AutoMapper.Mapper.Map(p, inventory);
                inventoryStocks.Add(mapped);
            }

            result.Count           = inventoryStocks.Count;
            result.TerminalLogId   = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, inventoryStocks.Count, terminal.TerminalId, TerminalLogTypeEnum.InventoryStockSync).TerminalLogId;
            result.InventoryStocks = inventoryStocks;
            return(Ok(result));
        }