当前位置: 首页>>代码示例>>C#>>正文


C# ProductRepository.GetItem方法代码示例

本文整理汇总了C#中ProductRepository.GetItem方法的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository.GetItem方法的具体用法?C# ProductRepository.GetItem怎么用?C# ProductRepository.GetItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductRepository的用法示例。


在下文中一共展示了ProductRepository.GetItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DealTest

 public void DealTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product dealingProduct = new Product(1, "House", "MOPRa,1", "for sale");
     _productRepository.Add(dealingProduct);
     Realtor.Deal(_productRepository, dealingProduct.id);
     Product expected = new Product(1, "House", "MOPRa,1", "saled");
     Product actual = _productRepository.GetItem(dealingProduct.id);
     Assert.AreEqual(true, true);
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:11,代码来源:Tests.cs

示例2: IsAvailable

        /// <summary>
        /// Method check, if Product is Available
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static bool IsAvailable(Product product)
        {
            IRepository<Product> _productRepository = new ProductRepository();

            if (_productRepository.GetItem(product.id).status == "saled")
            {
                return false;
            }
            else
            {
                return true;
            }
        }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:18,代码来源:Realtor.cs

示例3: RepositoryUpdateTest

 public void RepositoryUpdateTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product product = new Product(1, "House", "MOPRa,1", "for sale");
     _productRepository.Add(product);
     product.status = "saled";
     _productRepository.Update(product);
     Product actual = _productRepository.GetItem(product.id);
     Product expected = new Product(1, "House", "MOPRa,1", "saled");
     Assert.AreEqual(actual.id, product.id);
     Assert.AreEqual(actual.name, product.name);
     Assert.AreEqual(actual.status, product.status);
     Assert.AreEqual(actual.address, product.address);
     Program.ClearInformation();
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:16,代码来源:Tests.cs

示例4: RepositoryRemoveTest

 public void RepositoryRemoveTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product product = new Product(1, "House", "MOPRa,1", "for sale");
     _productRepository.Add(product);
     _productRepository.Remove(product.id);
     Product actual = _productRepository.GetItem(product.id);
     Product expected = null;
     Assert.AreEqual(expected, actual);
     Program.ClearInformation();
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:12,代码来源:Tests.cs

示例5: Main

        static void Main(string[] args)
        {
            ClearInformation();
            AutoFilling();

            while (true)
            {

                IRepository<Client> _clientRepository = new ClientRepository();
                IRepository<Product> _productRepository = new ProductRepository();
                IRepository<Manager> _managerRepository = new ManagerRepository();
                IEnumerable<Client> clientRepository = _clientRepository.GetItems();
                IEnumerable<Product> productRepository = _productRepository.GetItems();
                IEnumerable<Manager> managerRepository = _managerRepository.GetItems();
                Console.Write("The assortment of products \n");

                Realtor.PrintAssortment(productRepository);

                int countOfProducts = _productRepository.GetItems().Count();
                int countOfClients = _clientRepository.GetItems().Count();
                int countOfManagers = _managerRepository.GetItems().Count();

                Console.WriteLine("What do you want to buy?");
                int id = 0;

                while (true)
                {
                    Realtor.ChooseProduct(ref id);
                    Realtor.ChooseManager(_managerRepository);

                    if (id < 0 || id > countOfProducts)
                    {
                        Console.WriteLine("Incorrect number. Try again. A number of products is: {0} ", countOfProducts);
                    }
                    else
                    {
                        break;
                    }
                }

                if (!Realtor.IsAvailable(_productRepository.GetItem(id)))
                {
                    Console.WriteLine("Sorry. This product is saled");
                }

                else
                {

                    Console.WriteLine("Enter your Name");
                    string name = Console.ReadLine();

                    if (!Realtor.IsExistingClient(clientRepository,name))
                    {
                        Console.WriteLine("You are new client. You will be saved in our database");
                        countOfClients += 1;
                        Realtor.RememberClient(_clientRepository, countOfClients, name);

                    }

                    Realtor.Deal(_productRepository, id);

                }

                Console.ReadKey();
               if (!Realtor.Proceed())

                    break;
                else Console.Clear();
            }
        }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:70,代码来源:Program.cs

示例6: Buy

 public ActionResult Buy(Product product)
 {
     IRepository<Product> _productRepository = new ProductRepository();
     Product buyingProduct = _productRepository.GetItem(product.id);
     if (buyingProduct.status == "saled")
     {
         return RedirectToAction("ErrorOfSaledProduct");
     }
     else
     {
         buyingProduct.status = "saled";
         _productRepository.Update(buyingProduct);
         return RedirectToAction("Shop");
     }
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:15,代码来源:HomeController.cs


注:本文中的ProductRepository.GetItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。