Problem :
We have an Entity called Application, each application can have multiple products and a product may occure in more than one application, we want users to view all the products of an application
This is what I have done:
I chose Manufacturer since it has image and two existing ASP forms
1- Created two tables: Application like Manufacturer and another table callled Product_Application_mapping
2- Duplicated these ASP controls ManufactureList.ascx and ManufacturerProducts.ascx and respectively named them ApplicationList.ascx and ApplicationProducts.ascx
3- Added the new blocks to DCS_Block_Type_lkp
INSERT INTO DSC_Block_Type_lkp (type, virtualPath) VALUES ('Application Products', '/Store/ApplicationProducts.ascx')
INSERT INTO DSC_Block_Type_Group_Block_Type_Map (BlockTypeGroupId, BlockTypeId, SortOrder) VALUES (3, 86, 10)
4- Now we have an Application List that is working just Like Manufacturer List
This is it what we need: The ApplicationProduct.ascx shoud shows products for the selected application
Here in Page Load of ApplicationProducts transformed from ManufacuturProducts
protected void Page_Load(object sender, EventArgs e) {
............................
applicationId = Utils.GetIntParameter("mid", 0);
if (0 == applicationId)
Response.Redirect(SiteNavigation.Error404Page);
using (DSCComDataContext dc = DSCComDataContext.GetDataContext()) {
application = dc.Applications.Single(m => m.ApplicationId == applicationId);
}
LoadMetaTags();
int pageNumber = Utils.GetIntParameter("page", 1);
int productPerPage = applicationProductData.ProductsPerPage;
int totalNumber = 0;
List<Product> products = Product.GetProducts(null, productPerPage,
(pageNumber - 1) * productPerPage, (ProductSortBy)Utils.GetIntParameter("sortby", 0), application.Name,
Utils.GetNullableDecimalParameter("pricefrom"), Utils.GetNullableDecimalParameter("priceto"),
StoreConfigurationSection.GetSection().ShowStock, out totalNumber);
......
}
1- I need to have my tables added to DSCComDataSourceDataContext LINQ DataSources
2-Need to have Application metadata just like Manufacturer metadata
3- I need to have a new Product.GetProducts to filter product by this query in detail form
Select P.*
From dbo.DSC_Product P inner join [USI_Application_Product_Map] Ap on P.productId = Ap.productId
Where Ap.applicationId = @appID
Or if you suggest a code that does not require to touch the above DSC resources and is easier.
|