Ejemplo n.º 1
0
        public void OrderDelivered(int orderId)
        {
            var orderDelivered = this.InProgressOrders.Where(x => x.Id == orderId).FirstOrDefault();

            if (orderDelivered == null)
            {
                orderDelivered = AddedOrders.Where(x => x.Id == orderId).FirstOrDefault();
            }

            if (orderDelivered == null)
            {
                return;
            }

            orderDelivered.Status = OrderStatus.Delivered;

            OrderFinishedListItem finished = (OrderFinishedListItem)orderDelivered;

            finished.DeliveredTime = DateTime.Now;

            this.FinishedOrders.Add(finished);
            this.FinishedOrdersUpdated?.Invoke(this, null);

            this.InProgressOrders.Remove(orderDelivered);
            this.InProgressOrdersUpdated?.Invoke(this, new ServiceEvent <SalepointInProgressOrdersEvents>(SalepointInProgressOrdersEvents.RemovedOrder, orderDelivered));

            CrossLocalNotifications.Current.Show("Dostarczono zamówienie", string.Concat("Do miejsca: ", orderDelivered.DestinationAddress), orderDelivered.Id);
        }
Ejemplo n.º 2
0
        public async Task Cancel(OrderSalepoint order)
        {
            await this.salepointOrdersApi.CancelOrder(order.Id);

            order.Status = OrderStatus.Cancelled;
            OrderFinishedListItem finished = (OrderFinishedListItem)order;

            finished.CancellationTime = DateTime.Now;

            this.FinishedOrders.Add(finished);
            this.FinishedOrdersUpdated.Invoke(this, null);

            if (this.AddedOrders.Contains(order))
            {
                this.AddedOrders.Remove(order);
                this.AddedOrdersUpdated?.Invoke(this, new ServiceEvent <SalepointAddedOrdersEvents>(SalepointAddedOrdersEvents.RemovedOrder, order));
            }

            if (this.InProgressOrders.Contains(order))
            {
                this.InProgressOrders.Remove(order);
                this.InProgressOrdersUpdated?.Invoke(this, new ServiceEvent <SalepointInProgressOrdersEvents>(SalepointInProgressOrdersEvents.RemovedOrder, order));
            }
        }