Example #1
0
        public async Task <ItemsState> LoadInitialPageState(Func <Task> OnFailureCallback, IAsyncRetryFragmentCreator fragmentCreator)
        {
            try
            {
                var stores = await apiClient.GetAllActiveStoresAsync();

                var manufacturers = await apiClient.GetAllActiveManufacturersAsync();

                var itemCategories = await apiClient.GetAllActiveItemCategoriesAsync();

                var quantityTypes = await apiClient.GetAllQuantityTypesAsync();

                var quantityTypesInPacket = await apiClient.GetAllQuantityTypesInPacketAsync();

                return(new ItemsState(
                           stores,
                           itemCategories,
                           manufacturers,
                           quantityTypes,
                           quantityTypesInPacket));
            }
            catch (Exception e)
            {
                var fragment = fragmentCreator.CreateAsyncRetryFragment(OnFailureCallback);
                notificationService.NotifyError("Page loading failed", e.Message, fragment);
            }
            return(null);
        }
Example #2
0
        public async Task <ShoppingListRoot> LoadActiveShoppingListAsync(int storeId, Func <Task> OnFailure,
                                                                         IAsyncRetryFragmentCreator fragmentCreator)
        {
            try
            {
                return(await apiClient.GetActiveShoppingListByStoreIdAsync(storeId));
            }
            catch (Exception e)
            {
                var fragment = fragmentCreator.CreateAsyncRetryFragment(OnFailure);
                notificationService.NotifyError("Loading shopping list failed", e.Message, fragment);
            }

            return(null);
        }
        public async Task <bool> SaveStoreAsync(ModifyStoreRequest request, Func <Task> OnFailure, IAsyncRetryFragmentCreator fragmentCreator)
        {
            try
            {
                await apiClient.ModifyStoreAsync(request);

                return(true);
            }
            catch (Exception e)
            {
                var fragment = fragmentCreator.CreateAsyncRetryFragment(async() => await OnFailure());
                notificationService.NotifyError("Saving store failed", e.Message, fragment);
            }

            return(false);
        }