예제 #1
0
파일: Main.cs 프로젝트: Tec4Gen/Sgu-Sharp
        private void btnShowAllProduct_Click(object sender, EventArgs e)
        {
            List <Product> allProduct = ProductLogic.GetAll();

            dataGridProduct.Rows.Clear();

            foreach (var item in allProduct)
            {
                dataGridProduct.Rows.Add(item.Id, item.Title, item.Price);
            }
        }
예제 #2
0
        public IActionResult All(int page = 0)
        {
            var viewModel = new AllProductViewModel
            {
                Page     = page,
                Products = logic.GetAll(page)
            };

            return(View(viewModel));
        }
예제 #3
0
 public ActionResult GetAllApplicantEducation()
 {
     try
     {
         var pocos = _logic.GetAll();
         return(pocos.Count > 0 ? Ok(pocos) : (ActionResult)NotFound());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
예제 #4
0
        public ActionResult GetAllProducts()
        {
            var products = _logic.GetAll();

            if (products == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(products));
            }
        }
예제 #5
0
        private void FillProductsDatagrid()
        {
            dgvProductsDetails.Rows.Clear();
            var products = _productLogic.GetAll();

            foreach (var product in products)
            {
                DataGridViewRow newRow = new DataGridViewRow();
                newRow.CreateCells(dgvProductsDetails);
                newRow.SetValues(
                    product.Id,
                    product.Category.Description,
                    product.ProductCode,
                    product.Description,
                    $"{product.Cost:C}",
                    $"{product.Price:C}",
                    !product.Disabled,
                    product.Category.Id
                    );
                dgvProductsDetails.Rows.Add(newRow);
            }
        }
예제 #6
0
        public ApiModule()
            : base("/api")
        {
            #region  ///  Help Page  ///
            Get["/help"] = x => View["help"];
            #endregion

            #region  ///  Category  ///

            #region  ///  /api/Categories/  ///
            Get["/categories"] = x =>
            {
                var logic = new CategoryLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Categories/1234  ///
            Get["/categories/{id:int}"] = x =>
            {
                var logic = new CategoryLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Customer  ///

            #region  ///  /api/Customers/  ///
            Get["/customers"] = x =>
            {
                var logic = new CustomerLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Customers/1234  ///
            Get["/customers/{id*}"] = x =>
            {
                var logic = new CustomerLogic();

                var result = logic.GetById((string)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Employee  ///

            #region  ///  /api/employees  ///
            Get["/employees"] = x =>
            {
                var logic = new EmployeeLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  ///  /api/employees/1234  ///
            Get["/employees/{id:int}"] = x =>
            {
                var logic = new EmployeeLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Order  ///

            #region  ///  /api/Orders/  ///
            Get["/orders"] = x =>
            {
                var logic = new OrderLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Orders/1234  ///
            Get["/orders/{id:int}"] = x =>
            {
                var logic = new OrderLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Product  ///

            #region  ///  /api/Products/  ///
            Get["/products"] = x =>
            {
                var logic = new ProductLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Products/1234  ///
            Get["/products/{id:int}"] = x =>
            {
                var logic = new ProductLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Region  ///

            #region  ///  /api/Regions/  ///
            Get["/regions"] = x =>
            {
                var logic = new RegionLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Regions/1234  ///
            Get["/regions/{id:int}"] = x =>
            {
                var logic = new RegionLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Shipper  ///

            #region  ///  /api/Shippers/  ///
            Get["/shippers"] = x =>
            {
                var logic = new ShipperLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Shippers/1234  ///
            Get["/shippers/{id:int}"] = x =>
            {
                var logic = new ShipperLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Supplier  ///

            #region  ///  /api/Suppliers/  ///
            Get["/suppliers"] = x =>
            {
                var logic = new SupplierLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Suppliers/1234  ///
            Get["/suppliers/{id:int}"] = x =>
            {
                var logic = new SupplierLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Territory  ///

            #region  ///  /api/Territories/  ///
            Get["/territories"] = x =>
            {
                var logic = new TerritoryLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Territories/1234  ///
            Get["/territories/{id:string}"] = x =>
            {
                var logic = new TerritoryLogic();

                var result = logic.GetById((string)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion
        }
예제 #7
0
        public ActionResult AddProduct(OrderViewModel order)
        {
            List <Product> allProducts = ProductLogic.GetAll();

            return(View(allProducts));
        }
예제 #8
0
        public ApiModule() : base("/api")
        {
            #region  ///  Help Page  ///
            Get["/help"] = x => View["help"];
            #endregion

            #region  ///  Category  ///

            #region  ///  /api/Categories/  ///
            Get["/categories"] = x =>
            {
                var logic = new CategoryLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Categories/1234  ///
            Get["/categories/{id:int}"] = x =>
            {
                var logic = new CategoryLogic();

                var result = logic.GetById((int)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Customer  ///

            #region  ///  /api/Customers/  ///
            Get["/customers"] = x =>
            {
                var logic = new CustomerLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Customers/1234  ///
            Get["/customers/{id*}"] = x =>
            {
                var logic = new CustomerLogic();

                var result = logic.GetById((string)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Employee  ///

            #region  ///  /api/employees  ///
            Get["/employees"] = x =>
            {
                var logic = new EmployeeLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  ///  /api/employees/1234  ///
            Get["/employees/{id:int}"] = x =>
            {
                var logic = new EmployeeLogic();

                var result = logic.GetById((int)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Order  ///

            #region  ///  /api/Orders/  ///
            Get["/orders"] = x =>
            {
                var logic = new OrderLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Orders/1234  ///
            Get["/orders/{id:int}"] = x =>
            {
                var logic = new OrderLogic();

                var result = logic.GetById((int)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Product  ///

            #region  ///  /api/Products/  ///
            Get["/products"] = x =>
            {
                var logic = new ProductLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Products/1234  ///
            Get["/products/{id:int}"] = x =>
            {
                var logic = new ProductLogic();

                var result = logic.GetById((int)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Region  ///

            #region  ///  /api/Regions/  ///
            Get["/regions"] = x =>
            {
                var logic = new RegionLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Regions/1234  ///
            Get["/regions/{id:int}"] = x =>
            {
                var logic = new RegionLogic();

                var result = logic.GetById((int)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Shipper  ///

            #region  ///  /api/Shippers/  ///
            Get["/shippers"] = x =>
            {
                var logic = new ShipperLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Shippers/1234  ///
            Get["/shippers/{id:int}"] = x =>
            {
                var logic = new ShipperLogic();

                var result = logic.GetById((int)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Supplier  ///

            #region  ///  /api/Suppliers/  ///
            Get["/suppliers"] = x =>
            {
                var logic = new SupplierLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Suppliers/1234  ///
            Get["/suppliers/{id:int}"] = x =>
            {
                var logic = new SupplierLogic();

                var result = logic.GetById((int)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion

            #region  ///  Territory  ///

            #region  ///  /api/Territories/  ///
            Get["/territories"] = x =>
            {
                var logic = new TerritoryLogic();

                var result = logic.GetAll();

                return(Response.AsJson(result));
            };
            #endregion

            #region  /// /api/Territories/1234  ///
            Get["/territories/{id:string}"] = x =>
            {
                var logic = new TerritoryLogic();

                var result = logic.GetById((string)x.id);

                return(Response.AsJson(result));
            };
            #endregion

            #endregion
        }
예제 #9
0
        static void Main(string[] args)
        {
            bool flag = true;

            while (flag)
            {
                ProductLogic ProductLogic = new ProductLogic();
                StockLogic   StockLogic   = new 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 <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);
                            Stock    stock   = new 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();
                }
            }
        }
예제 #10
0
 public IEnumerable <Product> GetAllProducts()
 {
     return(_productLogic.GetAll());
 }