public static void DeleteRestaurant(Restaurant restaurantToDelete) { foreach (var i in Orders.Items.Where(i => i.Item.RestId == restaurantToDelete.Id)) { Orders.Items.Remove(i); } foreach (var d in Dishes.Where(d => d.RestId == restaurantToDelete.Id).ToList()) { Dishes.Remove(d); } Restaurants.Remove(restaurantToDelete); SaveSystem.SaveAll(); CurrentRestaurant = Restaurants.FirstOrDefault(r => r.OwnerId == CurrentUser.Id); if (CurrentRestaurant == null && restaurantToDelete.OwnerId == CurrentUser.Id) { new AddRestaurantWindow().Show(); } }
private static void SetRestaurantRights() { CurrentRestaurant = Restaurants.FirstOrDefault(r => r.OwnerId == CurrentUser.Id); if (CurrentRestaurant == null) { new AddRestaurantWindow().Show(); } else { Window.Title = "Delivery Lab — " + CurrentRestaurant.Name; if (!CurrentRestaurant.IsVerified) { Window.Title += " (Не подтверждён)"; } Window.showOrder.Content = "Заказы"; Window.restaurantMenu.Visibility = Visibility.Visible; Window.clearOrderButton.Visibility = Visibility.Collapsed; if (Orders.Items.Any(i => i.Item.RestId == CurrentRestaurant.Id && !i.IsReady)) { new Alert("Есть новые заказы!", "У вас есть новые заказы,\nожидающие доставки").Show(); Window.ShowOrder("", new RoutedEventArgs()); } } }
public Restaurant GetRestaurant(int id) { return(Restaurants.FirstOrDefault(r => r.Id == id)); }