Esempio n. 1
0
        public ActionResult Index()
        {
            //suv test
            //OperationsStatus myStatus = new OperationsStatus();
            //Product p = _productBusiness.GetProduct(1001, myStatus);
            //suv test


            //_attributeBusiness.GetAllAttributeBySet(1,true);

            //Drop BInd
            ProductViewModel product = null;

            try
            {
                product = new ProductViewModel();
                List <SelectListItem> selectListItem = new List <SelectListItem>();
                //Supplier Drop down bind
                List <SupplierViewModel> supplierListVM = Mapper.Map <List <Supplier>, List <SupplierViewModel> >(_masterBusiness.GetAllSuppliers());
                foreach (SupplierViewModel svm in supplierListVM)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = svm.Name,
                        Value    = svm.ID.ToString(),
                        Selected = false
                    });
                }
                product.suppliers = selectListItem;
                //Manufacturer Drop down bind
                List <ManufacturerViewModel> manfactureListVM = Mapper.Map <List <Manufacturer>, List <ManufacturerViewModel> >(_masterBusiness.GetAllManufacturers());
                selectListItem = null;
                selectListItem = new List <SelectListItem>();
                foreach (ManufacturerViewModel mvm in manfactureListVM)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = mvm.Name,
                        Value    = mvm.ID.ToString(),
                        Selected = false
                    });
                }
                product.manufacturers = selectListItem;

                //AttributeSet Drop down bind
                List <AttributeSetViewModel> AttributeSetListVM = Mapper.Map <List <AttributeSet>, List <AttributeSetViewModel> >(_attributeSetBusiness.GetAllAttributeSet());
                AttributeSetListVM = AttributeSetListVM == null ? null : AttributeSetListVM.OrderBy(attset => attset.Name).ToList();
                selectListItem     = null;
                selectListItem     = new List <SelectListItem>();
                foreach (AttributeSetViewModel avm in AttributeSetListVM)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = avm.Name,
                        Value    = avm.ID.ToString(),
                        Selected = false
                    });
                }
                product.AttributeSets = selectListItem;
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(View(product));
        }
Esempio n. 2
0
 public string GetAllManufacturers()
 {
     try
     {
         List <ManufacturerViewModel> ManufacturerList = Mapper.Map <List <Manufacturer>, List <ManufacturerViewModel> >(_masterBusiness.GetAllManufacturers());
         return(JsonConvert.SerializeObject(new { Result = "OK", Records = ManufacturerList }));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
     }
 }