public List <Product> GetByCategory(Category category, int?take = null, int?skip = null) { var builder = new BuilderProduct(DbSet).IsVisible().InCategory(category); if (take != null && skip != null) { builder.AddPagging(skip.Value, take.Value); } return(builder.ToList()); }
public List <Product> Search(string phrase, int?take = null, int?skip = null) { var builder = new BuilderProduct(DbSet).IsVisible().SearchInNameOrDescriptionInFullDescription(phrase); if (take != null && skip != null) { builder.AddPagging(skip.Value, take.Value); } return(builder.ToList()); }
public List <Product> GetHighlighted(int?take = null, int?skip = null) { var builder = new BuilderProduct(DbSet).IsVisible().IsHighlighted(); if (take != null && skip != null) { builder.AddPagging(skip.Value, take.Value); } return(builder.ToList()); }
static void RunBuilder() { // 建造者关系一个产品的构造 // 产品构造通常很复杂或者需要分部构造 Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); // Construct two products director.Construct(b1); BuilderProduct p1 = b1.GetResult(); p1.Show(); director.Construct(b2); BuilderProduct p2 = b2.GetResult(); p2.Show(); }
public async Task Post_Product() { using (var context = new BelezaWebContext(DatabaseOptions)) { //arrange var product = BuilderProduct.BuildProductDTO(context, out int idItem, false); var mockRepo = new ProductService(context); var controller = new ProductsController(mockRepo); // Act var result = await controller.Post(product); // Assert var okResult = Assert.IsType <OkObjectResult>(result); var returnSession = Assert.IsAssignableFrom <ProductDTO>(okResult.Value); Assert.True(returnSession != null); //Clean database context.Database.EnsureDeleted(); } }
public Product GetWithCategories(int idProduct) { var builder = new BuilderProduct(DbSet).IncludeCategories().WhereIdProduct(idProduct); return(builder.Query.FirstOrDefault()); }
public int CountByCategory(Category category) { var builder = new BuilderProduct(DbSet).IsVisible().InCategory(category); return(builder.Count()); }
public int CountBySearch(string phrase) { var builder = new BuilderProduct(DbSet).IsVisible().SearchInNameOrDescriptionInFullDescription(phrase); return(builder.Count()); }
public override void BuilderPartB(BuilderProduct pb) { pb.AddPart("来自建造者B所建造的B部分"); }
public override void BuilderPartA(BuilderProduct pb) { pb.AddPart("来自建造者A所建造的A部分"); }
public abstract void BuilderPartB(BuilderProduct pb);
void EraseProduct() => _product = new BuilderProduct();