public ProductCategory Create(ProductCategory productCategory) { if (productCategory == null) { throw new ArgumentNullException("productCategory"); } if (productCategory.Id == Guid.Empty) { productCategory.Id = Guid.NewGuid(); } if (productCategory.ProductId == Guid.Empty) { throw new ArgumentNullException("ProductId"); } if (productCategory.CategoryId == Guid.Empty) { throw new ArgumentNullException("CategoryId"); } using (var connection = context.CreateConnection()) { connection.Execute(ProductCategoryQuery.Insert(productCategory)); return(productCategory); } }
public ProductCategory GetById(Guid id) { using (var connection = context.CreateConnection()) { return(connection.Query <ProductCategory>(ProductCategoryQuery.ById(id)).SingleOrDefault()); } }
public IEnumerable <Category> GetCategoriesByProductId(Guid id) { using (var connection = context.CreateConnection()) { return(connection.Query <Category>(ProductCategoryQuery.CategoriesByProductId(id))); } }
public IEnumerable <Product> GetProductsByCategoryId(Guid id) { using (var connection = context.CreateConnection()) { return(connection.Query <Product>(ProductCategoryQuery.ProductsByCategoryId(id))); } }
public void Delete(Guid id) { using (var connection = context.CreateConnection()) { connection.Execute(ProductCategoryQuery.Delete(id)); } }
public ProductCategory Update(ProductCategory productCategory) { using (var connection = context.CreateConnection()) { connection.Execute(ProductCategoryQuery.Update(productCategory)); return(productCategory); } }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance ProductCategory mock = CreateMockInstance(tm); bool result = DataRepository.ProductCategoryProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); ProductCategoryQuery query = new ProductCategoryQuery(); query.AppendEquals(ProductCategoryColumn.ProductCategoryId, mock.ProductCategoryId.ToString()); query.AppendEquals(ProductCategoryColumn.Name, mock.Name.ToString()); query.AppendEquals(ProductCategoryColumn.Rowguid, mock.Rowguid.ToString()); query.AppendEquals(ProductCategoryColumn.ModifiedDate, mock.ModifiedDate.ToString()); TList <ProductCategory> results = DataRepository.ProductCategoryProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
public async Task <IHttpActionResult> Get([FromUri] ProductCategoryQuery query) { var serviceRes = await _productCatService.Get(new ProductCategoryListRequest() { RequestOwner = User, Query = query ?? new ProductCategoryQuery() }); IHttpActionResult res = BadRequest(); if (serviceRes.Access == ResponseAccess.Granted) { res = Ok(serviceRes.Categories); } if (serviceRes.Access == ResponseAccess.Deny) { res = Unauthorized(serviceRes.Message); } return(res); }
private static IQueryable <ProductCategory> FilterByCategoryType(this IQueryable <ProductCategory> categories, ProductCategoryQuery query) { return(query.CheckByType ? categories.Where(x => x.CategoryType == query.CategoryType || x.CategoryType == CategoryType.Mixed) : categories); }
public static IQueryable <ProductCategory> FilterByQuery(this IQueryable <ProductCategory> categories, ProductCategoryQuery query) { return(categories.FilterByCategoryType(query).FilterByMapTreeView(query.MapForTreeView)); }