Пример #1
0
        public IHttpActionResult SaveInspectionReport(string serialNo, VehicleInspectionReportSync model)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(model.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var inspection = Mapper.Map(model, new VehicleInspection());

            inspection.TenantId = terminal.TenantId;
            inspection          = _inspectionService.SaveInspection(inspection, model.CurrentUserId, model.CheckedInspectionIds, true);
            var result = Mapper.Map(inspection, model);

            return(Ok(result));
        }
        public IHttpActionResult UpdatePalletProducts(PalletProductsSyncCollection palletProductCollection)
        {
            var terminal = TerminalServices.GetTerminalBySerial(palletProductCollection.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(palletProductCollection.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            foreach (var item in palletProductCollection.PalletProducts)
            {
                var result = _palletService.AddFulFillmentPalletProduct(AutoMapper.Mapper.Map <PalletProductsSync, PalletProductAddViewModel>(item));
                if (result != null && result.PalletProductID > 0)
                {
                    item.PalletProductID = result.PalletProductID;
                    item.PostedSuccess   = true;
                }
            }
            return(Ok(palletProductCollection));
        }
Пример #3
0
        public async Task <IHttpActionResult> RecordScannedProducts(StockTakeProductCodeScanRequest request)
        {
            if (!string.IsNullOrEmpty(request.SerialNo))
            {
                var terminal = TerminalServices.GetTerminalBySerial(request.SerialNo);

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

                var TransactionLog = TerminalServices.CheckTransactionLog(request.TransactionLogId, terminal.TerminalId);

                if (TransactionLog == true)
                {
                    return(Conflict());
                }
            }

            if (request.ScannedQuantity == 0)
            {
                request.ScannedQuantity = 1;
            }

            var result = await StockTakeApiService.RecordScannedProducts(request);

            return(Ok(result));
        }
Пример #4
0
        public IHttpActionResult VanSalesDailyReport(VanSalesDailyCashSync model)
        {
            var serialNumber = model.SerialNumber.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNumber);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(model.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            model.TenantId = terminal.TenantId;


            var result = _vanSalesService.SaveVanSalesDailyReport(model);

            var terminalLog = TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, 0, terminal.TerminalId, TerminalLogTypeEnum.VanSalesDailyReport).TerminalLogId;

            var report = Mapper.Map <VanSalesDailyCash, VanSalesDailyCashSync>(result);

            report.UserId       = model.UserId;
            report.SerialNumber = model.SerialNumber;
            report.TerminalId   = model.TerminalId;
            return(Ok(report));
        }
Пример #5
0
        public async Task <IHttpActionResult> AcceptMarketJobRequest(MarketJobSync request)
        {
            request.SerialNumber = request.SerialNumber.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(request.SerialNumber);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(request.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var marketJob = _marketServices.GetMarketJobById(request.MarketJobId);

            if (marketJob.Id == 0)
            {
                return(NotFound());
            }

            var result = await _marketServices.AcceptMarketJob(request.MarketJobId, request.UserId, terminal.TenantId, terminal.TermainlSerial, request.Latitude, request.Longitude);

            return(Ok(result));
        }
        // POST http://ganetest.qsrtime.net/api/sync/post-order-processes
        public async Task <IHttpActionResult> PostOrderProcesses(OrderProcessesSyncCollection data)
        {
            data.SerialNo = data.SerialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(data.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(data.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                terminal.WarehouseId = mobileLocation.WarehouseId;
            }

            var results = new List <OrdersSync>();

            if (data.OrderProcesses != null && data.OrderProcesses.Any())
            {
                var groupedOrderProcesses = data.OrderProcesses.GroupBy(p => p.OrderToken, (key, g) => new { OrderToken = key, OrderProcesses = g.ToList() });

                foreach (var processGroup in groupedOrderProcesses)
                {
                    var orderProcesses = processGroup.OrderProcesses;
                    foreach (var item in orderProcesses)
                    {
                        var order = OrderService.SaveOrderProcessSync(item, terminal);

                        results.Add(order);

                        if (order.OrderStatusID == (int)OrderStatusEnum.AwaitingAuthorisation)
                        {
                            OrderViewModel orderViewModel = new OrderViewModel();
                            orderViewModel.OrderID   = order.OrderID;
                            orderViewModel.TenentId  = order.TenentId;
                            orderViewModel.AccountID = order.AccountID;
                            await _configHelper.CreateTenantEmailNotificationQueue($"#{order.OrderNumber} - Order Requires Authorisation", orderViewModel, null, shipmentAndRecipientInfo : null,
                                                                                   worksOrderNotificationType : WorksOrderNotificationTypeEnum.AwaitingOrderTemplate);
                        }
                    }
                }
            }

            TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, data.OrderProcesses.Count, terminal.TerminalId, TerminalLogTypeEnum.OrderProcessesPost);

            return(Ok(results));
        }
Пример #7
0
        // POST http://localhost:8005/api/sync/post-pallet-tracking
        public IHttpActionResult PostPallettracking(PalletTrackingSyncCollection data)
        {
            data.SerialNo = data.SerialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(data.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(data.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                terminal.WarehouseId = mobileLocation.WarehouseId;
            }

            var results = new PalletTrackingSyncCollection();

            if (data.PalletTrackingSync != null && data.PalletTrackingSync.Any())
            {
                foreach (var item in data.PalletTrackingSync)
                {
                    item.DateUpdated = DateTime.UtcNow;
                    var pallet = ProductServices.SavePalletTrackings(item, terminal.TenantId);

                    results.PalletTrackingSync.Add(pallet);
                    results.Count += 1;
                }
            }

            TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, data.PalletTrackingSync.Count, terminal.TerminalId, TerminalLogTypeEnum.PostPalletTracking);

            return(Ok(results));
        }
        // POST http://localhost:8005/api/sync/post-order-receive-count
        public IHttpActionResult PostOrderReceiveCount(OrderReceiveCountSyncCollection data)
        {
            data.SerialNo = data.SerialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(data.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(data.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                terminal.WarehouseId = mobileLocation.WarehouseId;
            }

            var results = new OrderReceiveCountSyncCollection();

            if (data.OrderReceiveCountSync != null && data.OrderReceiveCountSync.Any())
            {
                foreach (var item in data.OrderReceiveCountSync)
                {
                    var countRecord = OrderService.SaveOrderReceiveCount(item, terminal);

                    results.OrderReceiveCountSync.Add(countRecord);
                    results.Count += 1;
                }
            }

            TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, data.OrderReceiveCountSync.Count, terminal.TerminalId, TerminalLogTypeEnum.PostOrderReceiveCount);

            return(Ok(results));
        }
        public IHttpActionResult PostDispatchProgress(PalletDispatchProgress progress)
        {
            var terminal = TerminalServices.GetTerminalBySerial(progress.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(progress.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var result = _palletService.UpdateDispatchProgress(progress, progress.CreatedBy);

            return(Ok(result));
        }
        public IHttpActionResult DispatchPallet(PalletSync pallet)
        {
            var terminal = TerminalServices.GetTerminalBySerial(pallet.SerialNumber);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(pallet.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var result = _palletService.DispatchPalletsFromHandheld(pallet, pallet.CreatedBy);

            return(Ok(result));
        }
        public IHttpActionResult UpdatePalletImages(PalletSync pallet)
        {
            var terminal = TerminalServices.GetTerminalBySerial(pallet.SerialNumber);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(pallet.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var result = _palletService.UpdatePalletProof(pallet.PalletNumber, pallet.ProofOfLoadingImageBytes);

            return(Ok(AutoMapper.Mapper.Map(result, new PalletSync())));
        }
Пример #12
0
        public IHttpActionResult CreateHolidayRequest(HolidayRequestSync model)
        {
            var serialNumber = model.SerialNumber.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNumber);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(model.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var result = _employeeServices.AddResourceHolidaySync(model, terminal.TenantId, model.UserId);

            return(Ok(result));
        }
Пример #13
0
        public async Task <IHttpActionResult> UpdateStockTakeDetailQuantity(StockDetailQuantityUpdateRequest request)
        {
            if (!string.IsNullOrEmpty(request.SerialNo))
            {
                var terminal = TerminalServices.GetTerminalBySerial(request.SerialNo);

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

                var TransactionLog = TerminalServices.CheckTransactionLog(request.TransactionLogId, terminal.TerminalId);

                if (TransactionLog == true)
                {
                    return(Conflict());
                }
            }


            var result = await StockTakeApiService.UpdateStockTakeDetailQuantity(request);

            return(Ok(result));
        }
Пример #14
0
        public async Task <IHttpActionResult> DeclineMarketJobRequest(MarketJobSync request)
        {
            request.SerialNumber = request.SerialNumber.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(request.SerialNumber);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(request.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var result = await _marketServices.DeclineMarketJob(request.MarketJobId, request.UserId, terminal.TenantId, request.Comment, terminal.TermainlSerial, request.Latitude, request.Longitude);

            request.LatestStatusID = result.MarketJobStatusId ?? 0;

            return(Ok(result));
        }
Пример #15
0
        public IHttpActionResult GoodsReturn(GoodsReturnRequestSync model)
        {
            var terminal = TerminalServices.GetTerminalBySerial(model.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(model.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            bool proccess = true;
            var  result   = AutoMapper.Mapper.Map(model, new GoodsReturnResponse());
            var  product  = _productService.GetProductMasterById(model.ProductId);

            if (product != null)
            {
                if (model.userId > 0)
                {
                    if (!product.Serialisable && !product.ProcessByPallet)
                    {
                        model.OrderId = Inventory.StockTransaction(model, null, null);
                    }
                    if (product.Serialisable)
                    {
                        if (model.ProductSerials != null || model.ProductSerials.Count > 0)
                        {
                            model.OrderId = Inventory.StockTransaction(model, null, null, null);
                        }
                        else
                        {
                            model.OrderId = -1;
                        }
                    }
                    if (product.ProcessByPallet)
                    {
                        if (model.InventoryTransactionType.HasValue && (model.InventoryTransactionType == (int)InventoryTransactionTypeEnum.PurchaseOrder || model.InventoryTransactionType == (int)InventoryTransactionTypeEnum.SalesOrder))
                        {
                            proccess = false;
                        }
                        model.OrderId = _purchaseOrderService.ProcessPalletTrackingSerial(model, null, proccess);
                    }

                    if (model.OrderId >= 0)
                    {
                        result.IsSuccess  = true;
                        result.CanProceed = true;
                        result.orderId    = model.OrderId;
                    }
                    else
                    {
                        result.IsSuccess      = false;
                        result.CanProceed     = false;
                        result.FailureMessage = "Serialisable products must have serials along with stock.";
                    }
                }
                else
                {
                    result.FailureMessage = "User Id must be greater than 0.";
                }
            }
            else
            {
                result.FailureMessage = "Product not found.";
            }


            return(Ok(result));
        }