//
        // GET: /BillOfMaterial/

        public ActionResult Add(string ID)
        {
            ViewBag.FinishedProductList    = ProductLogic.GetFinishedProducts();
            ViewBag.RawMaterialProductList = ProductLogic.GetRawMaterialProducts();
            ViewBag.BOMProcessList         = BOMProcessLogic.BOMProcessByID(0);
            ViewBag.UnitList      = ProductUnitLogic.GetProductUnitByID(0);
            ViewBag.LabParameters = LabParameterLogic.GetLabParameterByID(0);
            ViewBag.UserType      = currUser.Type;
            if (Convert.ToInt32(ID) > 0)
            {
                var bom = BillOfMaterialLogic.GetBillOfMaterialByID(Convert.ToInt32(ID)).FirstOrDefault();
                ViewBag.ShadeList = ShadeLogic.GetShadeByProductID(Convert.ToInt32(bom.ProductID)).Select(x => new { x.ShadeID, x.ShadeName }).Distinct();
                //var productShades = ShadeLogic.GetShadeByProductID(bom.ProductID);
                //if (productShades != null && productShades.Count() > 0)
                //{
                //    foreach (var productShade in productShades.Select(x => x.ShadeID).Distinct())
                //    {
                //        ViewBag.ShadeList = ShadeLogic.GetShadeByID(Convert.ToInt32(productShade));
                //    }
                //}
                //else
                //{
                //    ViewBag.ShadeList = null;
                //}
                return(View(bom));
            }
            else
            {
                ViewBag.ShadeList = null;
                return(View(new BillOfMaterial()));
            }
        }
        //
        // GET: /Product/

        public ActionResult Add(string ID)
        {
            ViewBag.Shades           = ShadeLogic.GetShadeByID(0);
            ViewBag.Packings         = PackingLogic.GetPackingByID(0);
            ViewBag.ProductGroups    = ProductGroupLogic.GetProductGroupByID(0);
            ViewBag.ProductUnits     = ProductUnitLogic.GetProductUnitByID(0);
            ViewBag.Parties          = PartyLogic.GetPartyByID(0).Select(x => new { x.ID, x.Name });
            ViewBag.RawMaterialTypes = RawMaterialTypeLogic.RawMaterialTypeByID(0);
            if (Convert.ToInt32(ID) > 0)
            {
                var product = ProductLogic.GetProductByID(Convert.ToInt32(ID)).FirstOrDefault();
                return(View(product));
            }
            else
            {
                return(View(new Product()));
            }
        }