public ActionResult CreateProduct(BusinessEntities.DropDownList ProductCategories, string Name, double MinQuantity, string BtnSubmit) { BusinessEntities.Product p = new BusinessEntities.Product(Name, ProductCategories.SelectedItemId, MinQuantity); BusinessLayer.ProductBusinessLayer l = new BusinessLayer.ProductBusinessLayer(); l.CreateProduct(p); return RedirectToAction("Index"); }
public List<BusinessEntities.Product> GetProducts() { List<BusinessEntities.Product> Result = new List<BusinessEntities.Product>(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "exec dbo.spProductsGet"; DataTable dtProducts = DBContext.DBContext.Instance.GetSQLTable(cmd); foreach(DataRow r in dtProducts.Rows) { BusinessEntities.Product p = new BusinessEntities.Product((int)r["ProductId"], (string)r["Name"], (int)r["ProductCategoryId"], (double)r["MinQuantity"]); Result.Add(p); } return Result; }
/// <summary> /// This class will accepts the object holding ProductId and displays all the software of that product in box format. /// </summary> /// <param name="objProductRequest">Object holding ProductId of selected product</param> /// <returns>Software object having all the software of selected product with their specific details</returns> public List <BusinessEntities.Software> ShowSoftware(BusinessEntities.Product objProductRequest) { using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities()) { Data.Model.Product objProductDataRequest = new Data.Model.Product(); objProductDataRequest.ProductId = objProductRequest.ProductId; List <BusinessEntities.Software> softwareList = new List <BusinessEntities.Software>(); List <Data.Model.Software> softwareListData = new List <Data.Model.Software>(); softwareListData = DbContext.Softwares.ToList(); var result = from s in DbContext.Softwares join p in DbContext.Products on s.ProductId equals p.ProductId select new { ProductName = p.ProductName, SoftwareName = s.SoftwareName, SoftwareId = s.SoftwareId, ProductId = p.ProductId, SoftwareTypeId = s.SoftwareTypeId }; BusinessEntities.Software objSoftware = new BusinessEntities.Software(); BusinessEntities.Product objProduct = new BusinessEntities.Product(); if (objProductRequest.ProductId != -1) { result = result.Where(s => s.ProductId == objProductRequest.ProductId); } foreach (var s in result) { objSoftware = new BusinessEntities.Software(); objSoftware.SoftwareId = s.SoftwareId; objSoftware.SoftwareName = s.SoftwareName; objProduct = new BusinessEntities.Product(); objProduct.ProductId = s.ProductId; objProduct.ProductName = s.ProductName; objSoftware.Product = objProduct; softwareList.Add(objSoftware); } return(softwareList); } }
/// <summary> /// This method will return the list of all the product in the database /// </summary> /// <returns>Returns the list of all the product</returns> public List <BusinessEntities.Product> ShowProduct() { using (Data.Model.LicenseManagementMVCEntities DbContext = new LicenseManagementMVCEntities()) { List <BusinessEntities.Product> productList = new List <BusinessEntities.Product>(); List <Data.Model.Product> productListData = new List <Data.Model.Product>(); productListData = DbContext.Products.ToList(); BusinessEntities.Product objProduct = new BusinessEntities.Product(); foreach (var x in productListData) { objProduct = new BusinessEntities.Product(); objProduct.ProductName = x.ProductName; objProduct.ProductId = x.ProductId; productList.Add(objProduct); } return(productList); } }