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


C# ProductRepository.GetById方法代码示例

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


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

示例1: Details

 // GET: Product/Details/5
 public ActionResult Details(int id)
 {
     using (var productRep = new ProductRepository())
     {
         return View(productRep.GetById(id));
     }
 }
开发者ID:fabiopsouza,项目名称:Learning.AspNetMVC,代码行数:8,代码来源:ProductController.cs

示例2: Position

 public static Position Position(SupplyPosition pos)
 {
     var repo = new ProductRepository();
     var result = new Position
     {
         Lp = pos.Lp,
         Count = pos.Count,
         Product = repo.GetById(pos.ProductId.Id.ToString())
     };
     return result;
 }
开发者ID:Drazel,项目名称:Warehouse,代码行数:11,代码来源:ObjectMapper.cs

示例3: CalculateTotalShippingPrice

        public double CalculateTotalShippingPrice()
        {
            var productsCard = repository.GetAll();
            var productRepository = new ProductRepository(@"Repository\Product.txt", "ArrayOfProduct");
            double totalPrice = 0;
            foreach (var product in productsCard)
            {
                var productPrice = productRepository.GetById(int.Parse(product.IdProduct)).Price;
                totalPrice = totalPrice + productPrice;
            }

            return totalPrice;
        }
开发者ID:florentinac,项目名称:repository,代码行数:13,代码来源:ShippingProduct.cs

示例4: AddProduct

 public void AddProduct(OrderPosition position)
 {
     var id = position.ProductId.Id.ToString();
     var item = Products.Find(x => x.ProductId == id);
     if (item == null)
     {
         var repo = new ProductRepository();
         var product = repo.GetById(id);
         var productSum = new ProductSum(position.ProductId.Id.ToString(), product.Name, product.Ean, position.Count);
         Products.Add(productSum);
     }
     else
     {
         item.ProductCount += position.Count;
     }
 }
开发者ID:Drazel,项目名称:Warehouse,代码行数:16,代码来源:OutProductList.cs

示例5: ShouldGetAProductById

 public void ShouldGetAProductById()
 {
     var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
     var actualResult = productRepository.GetById(2);
     actualResult.ShouldNotBeNull();
 }
开发者ID:florentinac,项目名称:repository,代码行数:6,代码来源:ProductRepository.Tests.cs

示例6: Edit

 public ActionResult Edit(Guid id)
 {
     ProductRepository p = new ProductRepository(_sqlConnectionString);
     return View(p.GetById(id));
 }
开发者ID:MarneeDear,项目名称:Terminal-Management-Applications,代码行数:5,代码来源:ProductsController.cs

示例7: OrderDetail

        public ActionResult OrderDetail(OrderViewModel model)
        {
            OrderRepository orderRepo = new OrderRepository();
            OrderDetailRepository orderDetailRepo = new OrderDetailRepository();
            ProductRepository prodReop = new ProductRepository();

            Data.Order order = new Order();
            Data.OrderDetail orderDetail = new Data.OrderDetail();
            IEnumerable<Data.User> userList = userRepo.GetAllUsers();
            Data.User user = new Data.User();

            if (User.Identity.IsAuthenticated)
            {
                return PartialView("_OrderDetail", model);
            }
            else
            {

                foreach (Data.User u in userList)
                {
                    if (model.Email == u.EmailId)
                    {
                        //throw new ApplicationException("Email is already registered");
                        TempData["Msg"] = "Email is already registerd";
                        return RedirectToAction("CheckOut");
                    }
                }

                user.UserName = model.FirstName + " " + model.LastName;
                user.FirstName = model.FirstName;
                user.LastName = model.LastName;
                user.EmailId = model.Email;
                user.Password = model.Password;
                user.Role = "U";
                int userId = userRepo.Create(user);
                order.FKUserId = userId;
                int orderId = orderRepo.Create(order);
                productId = (IList<string>)Session["ProId"];

                foreach (var item in productId)
                {
                    int id = Convert.ToInt32(item);
                    orderDetail.FKOrderId = orderId;
                    orderDetail.FKProductId = id;
                    orderDetail.Status = "In Store";
                    orderDetail.Quantity = (int)prodReop.GetById(id).Quantity;
                    orderDetail.Cost = (decimal)prodReop.GetById(id).Price;
                    orderDetailRepo.Create(orderDetail);
                    //products.Add(db.Products.Find(productId));
                }

            }

            return PartialView("_OrderDetail", model);
        }
开发者ID:mahmoodali31,项目名称:shop,代码行数:55,代码来源:ShoppingCartController.cs


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