예제 #1
0
        public ActionResult Edit2(int id)
        {
            Quote quote;
            List <QuoteOption> options;

            using (var qm = new QuoteManager())
            {
                quote         = qm.Single(id);
                options       = qm.QuoteOptions(id).ToList();
                ViewBag.Quote = quote;
            }



            // determine the supplier and materials available
            List <CompanyToSupplier> companySuppliers;

            using (var sm = new SupplierManager())
            {
                companySuppliers = sm.ByCompanyID(quote.CompanyID.GetValueOrDefault()).ToList();
            }
            List <Product> products;

            using (var mm = new MaterialsManager())
            {
                List <Material> allMaterials = new List <Material>();
                foreach (var companyToSupplier in companySuppliers)
                {
                    allMaterials.AddRange(mm.BySupplier(companyToSupplier.SupplierID));
                }
                ViewBag.AvailableMaterials = allMaterials;

                products = mm.ActiveProducts(quote.CompanyID.GetValueOrDefault()).ToList();

                var productLines = mm.ActiveProductLines().ToList();
                ViewBag.PartsOfHouse         = productLines.AsEnumerable();
                ViewBag.ProductToProductLine = mm.AllProductToProductLine().ToList();
                ViewBag.MaterialToProducts   = mm.AllMaterialToProducts().ToList();
            }


            ViewBag.Products = products;


            return(View("Edit"));
        }