本文整理汇总了C#中ProductRepository.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository.Add方法的具体用法?C# ProductRepository.Add怎么用?C# ProductRepository.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductRepository
的用法示例。
在下文中一共展示了ProductRepository.Add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: InsertProductList
private static void InsertProductList(List<Product> list)
{
var repo = new ProductRepository();
foreach (var item in list)
{
repo.Add(item);
}
}
示例3: Add
public Product Add(ProductRepository spiritRepository)
{
var product = new Product
{
Name = "yeee"
};
var x = spiritRepository.Add(product);
return x;
}
示例4: IsAvailableTest
public void IsAvailableTest()
{
Program.ClearInformation();
IRepository<Product> _productRepository = new ProductRepository();
Product product = new Product(1, "House", "MOPRa,1", "saled");
_productRepository.Add(product);
bool actual = Realtor.IsAvailable(product);
bool expected = false;
Assert.AreEqual(expected, actual);
Program.ClearInformation();
}
示例5: 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);
}
示例6: AddProduct
//[TestMethod]
public void AddProduct()
{
// Arrange
Product prd = new Product()
{
Type = 3,
Name = "ccc",
Price = 11,
LinkUrl = "http://www.bb.com"
};
ProductRepository repository = new ProductRepository();
repository.Add(prd);
}
示例7: Main
static void Main(string[] args)
{
List<Product> result;
using (var db = new EfUnitOfWork(new InventoryContext()))
{
var repo = new ProductRepository(db);
repo.Add(new Product { Name = "One"});
repo.Add(new Product { Name = "Two" });
repo.Add(new Product { Name = "Three" });
repo.Add(new Product { Name = "Four" });
db.Commit();
result = repo.All().ToList();
}
foreach (var item in result)
{
System.Console.WriteLine(item.Name);
}
System.Console.ReadLine();
}
示例8: ProductRepositoryAddNewItemSaveItem
public void ProductRepositoryAddNewItemSaveItem()
{
//Arrange
var unitOfWork = new MainBcUnitOfWork();
IProductRepository productRepository = new ProductRepository(unitOfWork);
var book = new Book("The book title", "Any book description", "Krasis Press", "ABC");
book.ChangeUnitPrice(40);
book.IncrementStock(1);
book.GenerateNewIdentity();
//Act
productRepository.Add(book);
unitOfWork.Commit();
}
示例9: RepositoryGetTest
public void RepositoryGetTest()
{
Program.ClearInformation();
IRepository<Product> _productRepository = new ProductRepository();
Product[] product = new Product[2];
product[0] = new Product(1, "House", "MOPRa,1", "for sale");
product[1] = new Product(2, "House", "MOPRa,2", "for sale");
_productRepository.Add(product[0]);
_productRepository.Add(product[1]);
IEnumerable<Product> productRepository = _productRepository.GetItems();
for (int i = 1; i <= 2; i++)
{
Product actual = productRepository.Single(x => x.id == i);
Assert.AreEqual(actual.id, product[i - 1].id);
Assert.AreEqual(actual.name, product[i - 1].name);
Assert.AreEqual(actual.status, product[i - 1].status);
Assert.AreEqual(actual.address, product[i - 1].address);
}
Program.ClearInformation();
}
示例10: 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();
}
示例11: 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();
}
示例12: EditProductJustDocument
public void EditProductJustDocument()
{
var inizio = DateTime.Now;
IDocumentRepository docRep = new DocumentRepository();
IProductRepository prodRep = new ProductRepository();
PapiroService p = new PapiroService();
p.DocumentRepository = docRep;
p.CostDetailRepository = new CostDetailRepository();
p.TaskExecutorRepository = new TaskExecutorRepository();
p.ArticleRepository = new ArticleRepository();
Document doc = docRep.GetEstimateEcommerce("000001");
doc.EstimateNumber = "0";
DocumentProduct dp = docRep.GetDocumentProductsByCodProduct("").FirstOrDefault();
//work with product
Product prod = p.InitProduct("SuppRigidi", new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository());
//------passaggio del prodotto inizializzato all'ecommerce o alla view
prod.CodProduct = prodRep.GetNewCode(prod);
prod.ProductParts.FirstOrDefault().Format = "15x21";
prod.ProductParts.FirstOrDefault().SubjectNumber = 1;
var art = prod.ProductParts.FirstOrDefault().ProductPartPrintableArticles.FirstOrDefault();
#region Printable Article
IArticleRepository artRep = new ArticleRepository();
var artFormList = artRep.GetAll().OfType<RigidPrintableArticle>().FirstOrDefault();
art.TypeOfMaterial = artFormList.TypeOfMaterial;
art.NameOfMaterial = artFormList.NameOfMaterial;
art.Weight = artFormList.Weight;
art.Color = artFormList.Color;
#endregion
//------ritorno del prodotto modificato!!!!
//rigenero
prodRep.Add(prod);
prodRep.Save();
#region ViewModel
ProductViewModel pv = new ProductViewModel();
pv.Product = prod;
// prod.ProductCodeRigen();
pv.Quantity = 10;
#endregion
p.EditOrCreateAllCost(dp.CodDocumentProduct);
var fine = DateTime.Now.Subtract(inizio).TotalSeconds;
Assert.IsTrue(fine < 4);
}
示例13: AutoFilling
public static void AutoFilling()
{
Product[] product = new Product[10];
Client[] client = new Client[10];
Manager[] manager = new Manager[10];
product[0] = new Product(1, "House", "Moskovskaya, 320", "for sale");
product[1] = new Product(2, "Office", "MOPRa, 30", "for sale");
product[2] = new Product(3, "House", "Belorusskaya, 10", "for sale");
product[3] = new Product(4, "Bar", "MOPRa, 3", "for sale");
product[4] = new Product(5, "House", "Leningradskaya, 35", "for sale");
product[5] = new Product(6, "Cafe", "Molodogvardeiskaya, 70", "for sale");
product[6] = new Product(7, "House", "Moskovskaya, 30", "for sale");
product[7] = new Product(8, "Club", "Zelenaya, 11", "for sale");
product[8] = new Product(9, "House", "Lugivaja, 11", "for sale");
product[9] = new Product(10, "Pizzeria", "Pionerskaya, 4", "for sale");
client[0] = new Client(1, "Fedor Dvinyatin");
client[1] = new Client(2, "Alexei Volkov");
client[2] = new Client(3, "Ivan Ivanov");
client[3] = new Client(4, "Petr Bojko");
client[4] = new Client(5, "Egor Valedinsky");
client[5] = new Client(6, "Alexander Evtuh");
client[6] = new Client(7, "Alexei Lohnitsky");
client[7] = new Client(8, "Mokin Alexander");
client[8] = new Client(9, "Pavlovets Sergey");
client[9] = new Client(10, "Igor Pujko");
manager[0] = new Manager(1, "Viktor Oniskevich");
manager[1] = new Manager(2, "Petr Glinskij");
manager[2] = new Manager(3, "Fedor Yakubuk");
manager[3] = new Manager(4, "Vasily Sapon");
manager[4] = new Manager(5, "Igor Ivanovskiy");
manager[5] = new Manager(6, "Alexander Dubrovsky");
manager[6] = new Manager(7, "Olga Golub");
manager[7] = new Manager(8, "Egor Pirozhkov");
manager[8] = new Manager(9, "Boris Zhukovich");
manager[9] = new Manager(10, "Igor Stepanchuk");
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);
}
for (int i = 0; i <= 9; i++)
{
_clientRepository.Add(client[i]);
_productRepository.Add(product[i]);
_managerRepository.Add(manager[i]);
}
}