// GET http://ganetest.qsrtime.net/api/sync/order-processes/{reqDate}/{serialNo}
        // GET http://ganetest.qsrtime.net/api/sync/order-processes/2014-11-23/920013c000814
        public IHttpActionResult GetOrderProcesses(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var accounts = _accountServices.GetAllAccountsSelectList(terminal.TenantId);

            var result = new OrderProcessesSyncCollection();

            var allorderProcess = OrderService.GetAllOrderProcesses(reqDate, 0, null, null, true);

            var orderProcesses = new List <OrderProcessesSync>();

            foreach (var item in allorderProcess)
            {
                var pSync = new OrderProcessesSync();
                AutoMapper.Mapper.Map(item, pSync);

                var orderProcessDetails = new List <OrderProcessDetailSync>();

                foreach (var p in item.OrderProcessDetail)
                {
                    var order = new OrderProcessDetailSync();
                    var pd    = AutoMapper.Mapper.Map(p, order);
                    orderProcessDetails.Add(pd);
                }
                pSync.OrderProcessDetails = orderProcessDetails;
                orderProcesses.Add(pSync);
            }

            result.Count         = orderProcesses.Count;
            result.TerminalLogId = TerminalServices
                                   .CreateTerminalLog(reqDate, terminal.TenantId, orderProcesses.Count, terminal.TerminalId,
                                                      TerminalLogTypeEnum.OrderProcessSync).TerminalLogId;
            result.OrderProcesses = orderProcesses;
            return(Ok(AutoMapper.Mapper.Map(result, new OrderProcessesSyncCollection())));
        }