Ejemplo n.º 1
0
        public void RunApp()
        {
            NextRun mostRecentNextRun = _nextRunRepository.GetMostRecent();

            if (mostRecentNextRun == null)
            {
                return;
            }

            var currentNextRun = new NextRun {
                RunComplete = DateTime.Now
            };

            List <QueueItem> nextBatchToProcess = _sapphireService.ListNextBatch(mostRecentNextRun.RunComplete);

            if (nextBatchToProcess == null)
            {
                return;
            }

            _queueRepository.Create(nextBatchToProcess);

            //currentNextRun.Status = NextRunStatusType.Processed;
            //_nextRunRepository.Create(currentNextRun);
        }
Ejemplo n.º 2
0
        public int?Create(CreateOrderViewModel order)
        {
            var objOrder = new Order(order.Items.Select(p => new OrderItem(p.IdMenuItem, p.Amount)).ToList(),
                                     order.DeliveryValue, order.IdCompanyBranch, order.IdCustomer);

            if (IsError())
            {
                return(null);
            }

            //distance
            var objCompanyBranchAddress = _addressRepository.GetCompanyBranchDapper(order.IdCompanyBranch);

            if (objCompanyBranchAddress == null)
            {
                AddError("Company branch address not found");
                return(null);
            }
            var objDeliveryAddress = _addressRepository.GetDelivereyAddressDapper(order.IdDeliveryAddress);

            if (objDeliveryAddress == null)
            {
                AddError("Delivery address not found");
                return(null);
            }

            var util     = new Util();
            var objQueue = new Queue(order.IdDeliveryAddress, objOrder, objOrder.IdCompanyBranch,
                                     util.CalculateDistence(objCompanyBranchAddress.Latitude, objCompanyBranchAddress.Longitude, objDeliveryAddress.Latitude, objDeliveryAddress.Longitude));

            _queueRepository.Create(objQueue);
            if (Commit())
            {
                return(objQueue.IdQueue);
            }
            return(null);
        }