Beispiel #1
0
        public FurnitureHomePage()
        {
            InitializeComponent();
            BindingContext = viewModel = new HomePageViewModel();
            Init();

            MessagingCenter.Subscribe <AddProductPage, bool>(this, "AddProduct", async(sender, isPromotion) =>
            {
                if (isPromotion)
                {
                    await viewModel.LoadPromotionProducts();
                }
                else
                {
                    await viewModel.LoadProducts();
                }
            });


            MessagingCenter.Subscribe <AddProductPage, FurnitureProduct>(this, "UpdateProduct", async(sender, product) =>
            {
                loadingPopup.IsVisible = true;
                if (viewModel.Products.Any(x => x.Id == product.Id))
                {
                    await viewModel.LoadProducts();
                }
                if (viewModel.PromotionProducts.Any(x => x.Id == product.Id))
                {
                    await viewModel.LoadPromotionProducts();
                }
                loadingPopup.IsVisible = false;
            });

            MessagingCenter.Subscribe <ProductDetailPageViewModel, Guid>(this, "DeleteProduct", async(sender, productId) =>
            {
                loadingPopup.IsVisible = true;
                if (viewModel.Products.Any(x => x.Id == productId))
                {
                    await viewModel.LoadProducts();
                }
                if (viewModel.PromotionProducts.Any(x => x.Id == productId))
                {
                    await viewModel.LoadPromotionProducts();
                }
                loadingPopup.IsVisible = false;
            });
            MessagingCenter.Subscribe <PromotionPage>(this, "AddProduct", async(sender) => {
                loadingPopup.IsVisible = true;
                await viewModel.LoadPromotionProducts();
                loadingPopup.IsVisible = false;
            });
        }
Beispiel #2
0
        public async void Init()
        {
            await Task.WhenAll(viewModel.LoadProducts(), viewModel.LoadPromotionProducts(), viewModel.LoadCategories(), viewModel.LoadSlideList(), viewModel.LoadAdvertise());

            SetUpSlideImages();
            LoadCategories();
            loadingPopup.IsVisible = false;
        }