本文整理汇总了C#中ProductRepository类的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository类的具体用法?C# ProductRepository怎么用?C# ProductRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProductRepository类属于命名空间,在下文中一共展示了ProductRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProductRepository_UpdateProduct_1IfUpdate
public void ProductRepository_UpdateProduct_1IfUpdate()
{
ProductRepository produtoRepository = new ProductRepository();
int actual = produtoRepository.Updates(new Product { ProductID = 1, Name = "Gurte IceCream", CategoryID = 1, Code = "200", PurchasePrice = 1, SalePrice = 2, Stock = new Stock { ProductID = 1, ManageStock = true, MaximunQuantity = 200, MinimunQuantity = 20 } });
//ClearConnection();
Assert.AreEqual(1, actual);
}
示例2: Index
// GET: Product
public ActionResult Index(string sort = "Name", bool sortReverse = false, int pageNumber = 1, string searchFor = "")
{
ViewBag.CurrentSort = sortReverse;
using (var productRep = new ProductRepository())
{
ViewBag.OnePageOfProducts = ((List<Product>)productRep.Get(sort, ViewBag.CurrentSort, searchFor)).ToPagedList(pageNumber, 10);
}
var allProducts = new List<ProductViewModel>();
foreach (var item in ViewBag.OnePageOfProducts)
{
allProducts.Add(new ProductViewModel()
{
Id = item.Id,
Name = item.Name,
Description = item.Description,
Preco = item.Preco,
PhotoOutput = item.Photo == null ? string.Empty :
String.Format("data:image/gif;base64,{0}", Convert.ToBase64String(item.Photo))
});
}
ViewBag.AllProducts = allProducts;
return View();
}
示例3: ProductRepository_GetAll_1
public void ProductRepository_GetAll_1()
{
ProductRepository produtoRepository = new ProductRepository();
int actual = produtoRepository.GetAlls().Count();
//ClearConnection();
Assert.AreEqual(0, actual);
}
示例4: ProductRepository_GetByID_GurteIceCream
public void ProductRepository_GetByID_GurteIceCream()
{
ProductRepository produtoRepository = new ProductRepository();
Product actual = produtoRepository.GetByIds(1);
//ClearConnection();
Assert.AreEqual("Gurte IceCream",actual.Name);
}
示例5: SubscriptionController
public SubscriptionController()
{
_repo = new VetRepository(new FnRDbContext());
_subRepo = new SubscriptionRepository(new FnRDbContext());
_userRepo = new UserRepository(new FnRDbContext());
_productRepo = new ProductRepository(new FnRDbContext());
}
示例6: ProductRepository_CreateProduct_2IfCreate
public void ProductRepository_CreateProduct_2IfCreate()
{
ProductRepository produtoRepository = new ProductRepository();
int actual = produtoRepository.Creates(new Product { Name = "Choco IceCream", CategoryID = 1, Code = "200", PurchasePrice = 1, SalePrice = 2, Stock = new Stock { ManageStock = true, MaximunQuantity = 200, MinimunQuantity = 20 } });
// ClearConnection();
Assert.AreEqual(2, actual);
}
示例7: FindAllProducts
//[TestMethod]
public void FindAllProducts()
{
ProductRepository repository = new ProductRepository();
var ret = repository.FindAll();
repository = new ProductRepository();
ret = repository.FindAll();
}
示例8: SaveProduct_CreateNewProduct_NewProductShouldBeInsertedToDatabase
public void SaveProduct_CreateNewProduct_NewProductShouldBeInsertedToDatabase()
{
int id = -1;
var expected = new GGTestProduct
{
Name = "Test Product",
Category = "Test Category",
IsExpired = true
};
using (var repository = new ProductRepository())
{
id = repository.SaveProduct(expected);
}
// Verify result
GGTestProduct actual;
using (var session = NHibernateHelper.OpenSession())
{
actual = session.Get<GGTestProduct>(id);
}
Assert.AreEqual(expected.Name, actual.Name);
Assert.AreEqual(expected.Category, actual.Category);
Assert.AreEqual(expected.IsExpired, actual.IsExpired);
}
示例9: Clear
public static void Clear()
{
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();
foreach (var item in clientRepository)
{
_clientRepository.Remove(item);
}
foreach (var item in productRepository)
{
_productRepository.Remove(item);
}
foreach (var item in managerRepository)
{
_managerRepository.Remove(item);
}
}
示例10: Put
// PUT api/products/5
public IEnumerable<Product> Put(int id, [FromBody]Product value)
{
ProductRepository repo = new ProductRepository();
value.ProductId = id;
repo.Update(value);
return repo.Retrieve();
}
示例11: ProductRepositoryAddNewItemSaveItem
public void ProductRepositoryAddNewItemSaveItem()
{
//Arrange
var unitOfWork = new MainBCUnitOfWork();
IProductRepository productRepository = new ProductRepository(unitOfWork);
var book = new Book()
{
Id = IdentityGenerator.NewSequentialGuid(),
ISBN = "ABC",
Publisher = "Krasiss Press",
Title = "The book title",
UnitPrice = 40,
Description = "Any book description",
AmountInStock = 1
};
//Act
productRepository.Add(book);
productRepository.UnitOfWork.Commit();
//Assert
var result = productRepository.Get(book.Id);
Assert.IsNotNull(result);
Assert.IsTrue(result.Id == book.Id);
}
示例12: Details
// GET: Product/Details/5
public ActionResult Details(int id)
{
using (var productRep = new ProductRepository())
{
return View(productRep.GetById(id));
}
}
示例13: Get
public IHttpActionResult Get(int id)
{
try
{
Product product;
var productRepository = new ProductRepository();
if (id > 0)
{
var products = productRepository.Retrieve();
product = products.FirstOrDefault(p => p.ProductId == id);
if (product == null)
{
return NotFound();
}
}
else
{
product = productRepository.Create();
}
return Ok(product);
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
示例14: Update_Product0_name_to_nill
public void Update_Product0_name_to_nill()
{
AutoMapper.Mapper.CreateMap<DataAvail.UralAppModel.Product, Product>()
.ForMember(p => p.id, opt => opt.MapFrom(p => p.Id))
.ForMember(p => p.name, opt => opt.MapFrom(p => p.Name));
AutoMapper.Mapper.CreateMap<Product, DataAvail.UralAppModel.Product>()
.ForMember(p => p.Id, opt => opt.MapFrom(p => p.id))
.ForMember(p => p.Name, opt => opt.MapFrom(p => p.name));
Product product = new Product { id = 0, name = "hip" };
using (var model = new UralAppModel.Model())
{
ProductRepository repo = new ProductRepository();
repo.SetContext(model);
repo.GetAll(new Microsoft.Data.Services.Toolkit.QueryModel.ODataQueryOperation());
repo.Save(product);
}
/*
UralAppServ.DataServiceProvider prr = new UralAppServ.DataServiceProvider(new Uri(@"http://localhost:3360/Service.svc/"));
var r = prr.Products.Where(p => p.id == 0).First();
r.name = "nill";
//prr.AttachTo("Products", r);
prr.UpdateObject(r);
prr.SaveChanges();
*/
}
示例15: Index
public ActionResult Index(int pageNumber = 1)
{
using (var productRep = new ProductRepository())
{
ViewBag.OnePageOfProducts = productRep.Get().ToPagedList(pageNumber, 8);
}
var allProducts = new List<ProductViewModel>();
foreach (var item in ViewBag.OnePageOfProducts)
{
allProducts.Add(new ProductViewModel()
{
Id = item.Id,
Name = item.Name,
Description = item.Description,
Preco = item.Preco,
PhotoOutput = item.Photo == null ? string.Empty :
String.Format("data:image/gif;base64,{0}", Convert.ToBase64String(item.Photo))
});
}
var countProducts = allProducts.Count();
ViewBag.FirstRowOfProductList = countProducts.Equals(0) ? null : allProducts.Take(4);
if (countProducts > 4)
ViewBag.SecondRowOfProductList = countProducts.Equals(0) ? null : allProducts.GetRange(4, countProducts - 4);
return View();
}