コード例 #1
0
 public void SetRestaurant(Restaurant rest)
 {
     MenuUrl = rest.GetMenuUrl();
 }
コード例 #2
0
 static async Task<List<Order>> FetchHistoryAsync(Restaurant rest)
 {
     using (var client = new HttpClient(new NativeMessageHandler()))
     {
         using (var req = new HttpRequestMessage(HttpMethod.Get, Configuration.Routes.OrderhistoryUrl + "?userid=" + LoginManager.LoggedinUser.UserId + "&restaurantId=" + rest.RestaurantId))
         {
             try
             {
                 var res = await client.RequestAsync<List<Order>>(req);
                 return res.Data;
             }
             catch (Exception e)
             {
                 throw new Exception("Unable to fetch history Error:" + e.FullMessage(), e);
             }
         }
     }
 }
コード例 #3
0
        public void SetRestaurant(Restaurant rest)
        {
            const string UpdateOrderTxt = "Edit my order";
            const string NewOrderTxt = "I am ready!";
            const string NewOrderButtonColor = "#81C134";
            const string UpdateOrderColor = "#ED8413";

            Restaurant = rest;
            MenuUrl = Restaurant.GetMenuUrl();
            Title = Restaurant.RestaurantName;
            OrderButtonText = NewOrderTxt;
            OrderButtonColor = Color.FromHex(NewOrderButtonColor);
            OrderButtonEnabled = false;
            CurrentOrder = null;
            ExistingOrder = null;
            //fetch the orders
            Task.Run(async () =>
                {
                    ExistingOrder = await DomainManager.GetCurrentOrder();
                    var filtered = await DomainManager.GetHistory(Restaurant.RestaurantId);
                    var currentOrder = filtered.FirstOrDefault(o => o.AddDate.ToLocalTime().Date == DateTime.Today);
                    Device.BeginInvokeOnMainThread(() =>
                        {
                            var hasOrderForToday = currentOrder != null;
                            if (hasOrderForToday)
                            {
                                OrderButtonText = UpdateOrderTxt;
                                OrderButtonColor = Color.FromHex(UpdateOrderColor);
                                CurrentOrder = currentOrder;
                                currentOrder.IsCurrentOrder = true;
                            }
                            else
                            {
                                OrderButtonText = NewOrderTxt;
                                OrderButtonColor = Color.FromHex(NewOrderButtonColor);
                                CurrentOrder = new Order() { RestaurantId = this.Restaurant.RestaurantId };
                            }

                            PreviousOrders = new ObservableCollection<Order>(filtered);
                            OrderButtonEnabled = true;
                        });
                });
        }