Пример #1
0
        public StockService(IStockLogic stockLogic, IWarehouseRepository warehouseRespository)
        {
            if (stockLogic == null)
            {
                throw new ArgumentNullException();
            }
            _stockLogic = stockLogic;

            if (warehouseRespository == null)
            {
                throw new ArgumentNullException();
            }
            _warehouseRespository = warehouseRespository;
        }
Пример #2
0
        public DesktopApp()
        {
            InitializeComponent();
            Context     context = new Context();
            IUnitOfWork uw      = new UnitOfWork(context);

            userLogic                               = new UserLogic(uw);
            adminLogic                              = new AdminLogic(uw);
            stockLogic                              = new StockLogic(uw);
            gameSettingsLogic                       = new GameSettingsLogic(uw);
            actualAdmin                             = new Admin();
            panelOptions.Visible                    = false;
            panelAdminMaintenace.Visible            = false;
            panelCreateStock.Visible                = false;
            panelModifyGameConditions.Visible       = false;
            panelCreateAdmin.Visible                = false;
            panelModifyDeleteStock.Visible          = false;
            textBoxPassword.PasswordChar            = '*';
            textBoxPasswordMaintenance.PasswordChar = '*';
            textBoxCreateAdminPassword.PasswordChar = '*';

            textBoxEmail.Text    = "*****@*****.**";
            textBoxPassword.Text = "Artoo.1234554";
        }
Пример #3
0
        static void Main(string[] args)
        {
            bool flag = true;

            while (flag)
            {
                IProductLogic ProductLogic = Dependency.Dependency.ClientLogic;
                IStockLogic   StockLogic   = Dependency.Dependency.StockLogic;

                Console.WriteLine("=>Выберите действие<=");
                Console.WriteLine(new String('*', 20));
                Console.WriteLine("1)Посмотреть товары");
                Console.WriteLine("2)Добавить товар");
                Console.WriteLine("3)Удалить товар");
                Console.WriteLine("4)Найти товар по названию");
                Console.WriteLine(new String('*', 20));
                Console.WriteLine("5)Посмотреть акции");
                Console.WriteLine("6)Добавить акцию");
                Console.WriteLine("7)Удалить акцию");
                Console.WriteLine("8)Найти акцию по дане");
                Console.WriteLine(new String('*', 20));
                Console.WriteLine("9)Выйти из программы");
                Console.WriteLine();
                string message = "Возврат в меню";

                if (int.TryParse(Console.ReadLine(), out int action))
                {
                    switch (action)
                    {
                    case 1:
                        List <Product> all = ProductLogic.GetAll();
                        if (all.Count == 0)
                        {
                            Console.WriteLine("Товаров нет");
                        }
                        Console.WriteLine("Все товары:");
                        foreach (var item in all)
                        {
                            Console.WriteLine($"{item.Id} {item.Title} {item.Price}");
                        }
                        Console.WriteLine();
                        break;

                    case 2:
                        Console.WriteLine("Введите");
                        Console.Write("Название:");
                        string title = Console.ReadLine();
                        Console.Write("Цену:");
                        if (!int.TryParse(Console.ReadLine(), out int Price))
                        {
                            Console.WriteLine("неверная цена, возврат в меню");
                            break;
                        }
                        Product product = new Product
                        {
                            Price = Price,
                            Title = title,
                        };

                        ProductLogic.Add(product);

                        Console.WriteLine(new String('!', 20));
                        Console.WriteLine("Продукт добавлен");
                        Console.WriteLine(new String('!', 20));
                        Console.WriteLine();
                        break;

                    case 3:
                        Console.WriteLine("Введите id:");

                        if (int.TryParse(Console.ReadLine(), out int id))
                        {
                            ProductLogic.DeleteById(id);
                        }
                        else
                        {
                            Console.WriteLine("Не верное id");
                        }
                        Console.WriteLine();
                        break;

                    case 4:
                        Console.WriteLine("Введите название товара:");

                        string titile = Console.ReadLine();

                        var findList = ProductLogic.FindByTitile(titile);
                        if (findList != null)
                        {
                            if (findList.Count == 0)
                            {
                                Console.WriteLine("Товаров нет");
                                Console.WriteLine();
                                break;
                            }
                            Console.WriteLine("Найденые товары");
                            Console.WriteLine(new String('=', 20));
                            foreach (var item in findList)
                            {
                                Console.WriteLine($"{item.Id} {item.Title} {item.Price}");
                            }
                            Console.WriteLine(new String('=', 20));
                        }
                        else
                        {
                            Console.WriteLine("Товаров с таким названием нет");
                        }
                        Console.WriteLine();
                        break;

                    case 5:
                        List <SSU.Stock.Entities.Stock> allAcii = StockLogic.GetAll();
                        if (allAcii.Count == 0)
                        {
                            Console.WriteLine("Акций нет");
                            break;
                        }
                        Console.WriteLine("Все акции:");
                        foreach (var item in allAcii)
                        {
                            Console.WriteLine($"{item.Id} {item.Title} {item.Date.Date:MM/dd/yyyy}");
                        }
                        Console.WriteLine();
                        break;

                    case 6:
                        Console.WriteLine("Введите");
                        Console.Write("Название:");
                        string titleStock = Console.ReadLine();
                        Console.Write("Дату проведения ММ/ДД/ГГГГ:");
                        string dateString = Console.ReadLine();

                        try
                        {
                            DateTime dateAdd = DateTime.ParseExact(dateString, "MM/dd/yyyy", null);
                            SSU.Stock.Entities.Stock stock = new SSU.Stock.Entities.Stock
                            {
                                Title = titleStock,
                                Date  = dateAdd,
                            };

                            StockLogic.Add(stock);
                            Console.WriteLine(new String('!', 20));
                            Console.WriteLine("Акция добавлена");
                            Console.WriteLine(new String('!', 20));
                            Console.WriteLine();
                            break;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine(new String('!', 20));
                            Console.WriteLine("Неверная дата");
                            Console.WriteLine(new String('!', 20));
                            Console.WriteLine();
                            break;
                        }


                    case 7:
                        Console.WriteLine("Введите id:");

                        if (int.TryParse(Console.ReadLine(), out int idS))
                        {
                            StockLogic.DeleteById(idS);
                        }
                        else
                        {
                            Console.WriteLine("Не верное id");
                        }
                        Console.WriteLine();
                        break;

                    case 8:
                        DateTime date;
                        Console.Write("Введите дату ММ/ДД/ГГГГ:");
                        string dateFind = Console.ReadLine();
                        try
                        {
                            date = DateTime.ParseExact(dateFind, "MM/dd/yyyy", null);
                            var listStock = StockLogic.FindByDate(date);
                            if (listStock.Count == 0)
                            {
                                Console.WriteLine("Акций нет");
                                Console.WriteLine();
                                break;
                            }
                            Console.WriteLine("Найденые акции");
                            foreach (var item in listStock)
                            {
                                Console.WriteLine($"{item.Id} {item.Title} {item.Date.Date:MM/dd/yyyy}");
                            }
                            Console.WriteLine();
                        }
                        catch
                        {
                            Console.WriteLine("Введите нормальную дату: ММ/ДД/ГГГГ");
                        }
                        Console.WriteLine();
                        break;

                    case 9:
                        flag    = false;
                        message = "Завершение работы";
                        break;

                    default:
                        break;
                    }

                    Console.WriteLine(new String('!', 20));
                    Console.WriteLine(message);
                    Console.WriteLine(new String('!', 20));

                    Console.WriteLine("Нажмите любую кнопку что бы продолжить");
                    Console.ReadLine();
                }
            }
        }
Пример #4
0
 public StockController(IStockLogic stockLogic)
 {
     this.stockLogic = stockLogic;
 }