Beispiel #1
0
        public void getDropDownListDetails(Int32 vehicleId )
        {
            Dictionary<String, int> Vehicle = VehicleRepository.getCustAndBrandIdForVeh(vehicleId);

            DomainModel.Concrete.SQLCustomerRepository cusRepo = new DomainModel.Concrete.SQLCustomerRepository();
            var allCustomer = cusRepo.getCustomers();
            #region drop down select list
            List<drpDetails> customersForDpDwn = new List<drpDetails>();
            customersForDpDwn.Add(new drpDetails(0, "Select", false));
            foreach (var customer in allCustomer)
            {
                int? id = customer.ID;
                customersForDpDwn.Add(new drpDetails(customer.ID, customer.Name.ToString(), false));
            }
            var items = new SelectList(customersForDpDwn, "ID", "Name", Vehicle["customerId"]);
            #endregion
            if (vehicleId != 0)
            {

                DomainModel.Concrete.SQLBrandRepository bndRepo = new DomainModel.Concrete.SQLBrandRepository();
                var allBrands = bndRepo.getBrands();
                #region drop down select list
                List<drpDetails> brandsForDpDwn = new List<drpDetails>();
                brandsForDpDwn.Add(new drpDetails(0, "Select", false));
                foreach (var brand in allBrands)
                {
                    int? id = brand.ID;
                    brandsForDpDwn.Add(new drpDetails(brand.ID, brand.Name.ToString(), false));
                }
                var brandItems = new SelectList(brandsForDpDwn, "ID", "Name", Vehicle["brandId"]);
                #endregion
                ViewData["VehicleBrand"] = brandItems;
            }
            else
            {
                List<drpDetails> brandsForDpDwn = new List<drpDetails>();
                brandsForDpDwn.Add(new drpDetails(0, "Choose Customer", false));
                var brandItems = new SelectList(brandsForDpDwn, "ID", "Name", 0);
                ViewData["VehicleBrand"] = brandItems;
            }
            ViewData["VehicleCustomer"] = items;
        }
Beispiel #2
0
        public string getBrandsForCustomer(Int32 customerId)
        {
            DomainModel.Concrete.SQLBrandRepository brndRepo = new DomainModel.Concrete.SQLBrandRepository();
            var brands = brndRepo.getBrandsForCustomer(customerId);

            var brandsCh = (from b in brands
                              select new
                              {
                                  b.ID,
                                  b.Name
                              }).ToArray();
            JavaScriptSerializer sr = new JavaScriptSerializer();
            string nameList = sr.Serialize(brandsCh);
            return nameList;
        }