Example #1
0
 public ListViewModel(string title)
 {
     Title            = title;
     Items            = new ObservableRangeCollection <Item>();
     LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
     dataAccess       = new ItemsDataAccess();
 }
Example #2
0
        public ItemsListPage()
        {
            dataAccess     = new ItemsDataAccess();
            BindingContext = this.viewModel = new ListViewModel("Items", dataAccess);
            MessagingCenter.Send <ContentPage>(this, "refresh");

            InitializeComponent();
        }
Example #3
0
        public ItemDetailPage(Item item, ItemsDataAccess dataAccess)
        {
            InitializeComponent();

            this.dataAccess = dataAccess;
            this.item       = item;

            BindingContext = this.viewModel = new ItemDetailViewModel(item);
        }
        public UpdateItemPage(Item item, ItemsDataAccess dataAccess)
        {
            InitializeComponent();

            this.dataAccess = dataAccess;
            this.Item       = item;

            BindingContext = this;
        }
        public ListViewModel(string title, ItemsDataAccess dataAccess)
        {
            Title            = title;
            Items            = new ObservableRangeCollection <Item>();
            this.dataAccess  = dataAccess;
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            this.dataAccess  = dataAccess;

            MessagingCenter.Subscribe <ContentPage>(this, "refresh", (sender) => {
                ExecuteLoadItemsCommand();
            });
        }
        public AddItemPage(ItemsDataAccess dataAccess)
        {
            InitializeComponent();

            this.dataAccess = dataAccess;

            Item = new Item
            {
                ItemName = "Item name",
                Strength = 0,
                Health   = 0,
                Speed    = 0,
                Defense  = 0
            };

            BindingContext = this;
        }
Example #7
0
        public AddItemPage(ItemsDataAccess dataAccess)
        {
            if (!dataAccess.TestMode)
            {
                InitializeComponent();
                BindingContext = this;
            }

            this.dataAccess = dataAccess;

            Item = new Item
            {
                ItemName  = "Item name",
                Strength  = 0,
                Dexterity = 0,
                Speed     = 0,
                Defense   = 0
            };
        }
Example #8
0
        /// <summary>
        /// выводит самые популярные товары
        /// </summary>
        /// <param name="user"></param>
        public void ShowPopularGoods(User user)
        {
            List <Goods> products = new List <Goods>();
            int          count    = 4;

            using (var itemsDataAccess = new ItemsDataAccess())
            {
                products = itemsDataAccess.SelectPopularGoodsId(count).ToList();
                foreach (var product in products)
                {
                    product.Category     = itemsDataAccess.GetCategory(product);
                    product.Manufacturer = itemsDataAccess.GetManufacturer(product);
                    product.Raiting      = itemsDataAccess.GetRaiting(product);
                }
            }

            do
            {
                Console.Clear();
                Console.WriteLine("\t\tПолулярные товары:\n");
                PrintGoods(products);

                Console.WriteLine("Для просмотра всех товаров введите 0");
                Console.Write("Введите номер товара который хотите посмотреть -> ");
                int inputkey = int.Parse(Console.ReadLine());
                if (inputkey < 0 || inputkey > count)
                {
                    inputkey = 1;
                }
                else if (inputkey == 0)
                {
                    Start(user);
                }
                ShowGoods(products[inputkey - 1], inputkey, false);


                Console.ReadKey();
            } while (true);
        }
Example #9
0
 public Reset()
 {
     BindingContext = this;
     dataAccess     = new ItemsDataAccess();
     InitializeComponent();
 }
Example #10
0
        public void Start(User user)
        {
            var productsForPay = new List <Goods>();

            int countOfGoods = 0;

            using (var itemsDataAccess = new ItemsDataAccess())
            {
                countOfGoods = itemsDataAccess.GetCountOfGoods();
            }

            var products    = new List <Goods>();
            int offsetCount = 0;
            int fetchCount  = 4;

            var purchase    = new Purchase();
            var basket      = new Basket();
            var qiwiService = new QiwiService();

            do
            {
                Console.Clear();
                using (var itemsDataAccess = new ItemsDataAccess())
                {
                    products = itemsDataAccess.SelectGoods(offsetCount, fetchCount).ToList();

                    foreach (var product in products)
                    {
                        product.Category     = itemsDataAccess.GetCategory(product);
                        product.Manufacturer = itemsDataAccess.GetManufacturer(product);
                    }
                }
                Console.WriteLine("Для перемещения по странице нажмите на стрелочки <-назад | вперед->\t Для просмотра корзины нажмите на B");
                Console.WriteLine("\t\tOnlineShop\n");
                PrintGoods(products);
                Console.Write("Введите номер товара который хотите посмотреть -> ");

                var input = Console.ReadKey(true).Key;

                switch (input)
                {
                case ConsoleKey.NumPad1:
                    ShowGoods(products[0], 1, true);
                    var keyInput = Console.ReadKey(true).Key;
                    switch (keyInput)
                    {
                    case ConsoleKey.Tab:         //добавить в корзину
                        productsForPay.Add(products[0]);
                        break;
                    }
                    break;

                case ConsoleKey.NumPad2:
                    ShowGoods(products[1], 2, true);
                    keyInput = Console.ReadKey(true).Key;
                    switch (keyInput)
                    {
                    case ConsoleKey.Tab:         //добавить в корзину
                        productsForPay.Add(products[0]);
                        break;
                    }
                    break;

                case ConsoleKey.NumPad3:
                    ShowGoods(products[2], 3, true);
                    keyInput = Console.ReadKey(true).Key;
                    switch (keyInput)
                    {
                    case ConsoleKey.Tab:         //добавить в корзину
                        productsForPay.Add(products[0]);
                        break;
                    }
                    break;

                case ConsoleKey.NumPad4:
                    ShowGoods(products[3], 4, true);
                    keyInput = Console.ReadKey(true).Key;
                    switch (keyInput)
                    {
                    case ConsoleKey.Tab:         //добавить в корзину
                        productsForPay.Add(products[0]);
                        break;
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (offsetCount < countOfGoods - 4)
                    {
                        offsetCount += 4;
                    }
                    break;

                case ConsoleKey.LeftArrow:
                    if (offsetCount > 4)
                    {
                        offsetCount -= 4;
                    }
                    break;

                case ConsoleKey.B:     //ПОСМОТРЕТЬ ТОВАРЫ В КОРЗИНЕ
                    Console.Clear();
                    PrintGoods(productsForPay);
                    Console.WriteLine("Для покупки нажмите Q");
                    keyInput = Console.ReadKey(true).Key;
                    if (keyInput == ConsoleKey.Q)
                    {
                        purchase.products = productsForPay;
                        purchase.Date     = DateTime.Now;
                        purchase.UserId   = user.Id;
                        if (qiwiService.Pay(user, purchase) == Status.PAID.ToString())
                        {
                            Console.WriteLine("Оплата завершена!");
                            Console.Clear();
                            using (var purchaceDataAccess = new PurchaseDataAccess())
                            {
                                purchaceDataAccess.Insert(purchase);
                                using (var basketDataAccess = new BasketDataAccess())
                                {
                                    foreach (var good in productsForPay)
                                    {
                                        basket.GoodsId    = good.Id;
                                        basket.PurchaseId = purchase.Id;
                                        basketDataAccess.Insert(basket);
                                    }
                                }
                                foreach (var payProduct in productsForPay)
                                {
                                    purchaceDataAccess.UpdateGoodsAmount(payProduct);
                                }
                                productsForPay.Clear();     // очищаем корзину
                            }
                        }
                        else
                        {
                            Console.WriteLine("Произошла ошибка повторите позже");
                            Console.ReadKey();
                        }
                    }
                    break;
                }
            } while (true);
        }