本文整理汇总了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));
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例5: ShouldGetAProductById
public void ShouldGetAProductById()
{
var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
var actualResult = productRepository.GetById(2);
actualResult.ShouldNotBeNull();
}
示例6: Edit
public ActionResult Edit(Guid id)
{
ProductRepository p = new ProductRepository(_sqlConnectionString);
return View(p.GetById(id));
}
示例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);
}