Esempio n. 1
0
 internal static void EncodeTextPropertyofItems(this IDropDown instance)
 {
     foreach (DropDownItem item in instance.Items)
     {
         item.Text = HttpUtility.HtmlEncode(item.Text);
     }
 }
Esempio n. 2
0
        public ActionResult AddUser()
        {
            IDropDown dropDownRepo = RepositoryFactory.CreateDropDowns();
            UserVM    userVM       = new UserVM();

            userVM.SetRoles(dropDownRepo.RolesDropDown());
            return(View(userVM));
        }
 internal static void AddPlaceholderItem(this IDropDown instance)
 {
     if (instance.Placeholder.HasValue())
     {
         instance.Items.Insert(0, new DropDownItem
         {
             Text     = instance.Placeholder,
             Value    = string.Empty,
             Selected = false
         });
     }
 }
Esempio n. 4
0
        public ActionResult Add()
        {
            IDropDown    _dropdownrepo = RepositoryFactory.CreateDropDowns();
            CarViewModel carVM         = new CarViewModel();

            carVM.Car = new Car();
            carVM.SetMakes(_dropdownrepo.MakeDropdown());
            carVM.SetModels(_dropdownrepo.ModelDropdown());
            carVM.SetTypes(_dropdownrepo.TypeDropdown());
            carVM.SetBodyStyles(_dropdownrepo.BodyStyleDropdown());
            carVM.SetTransmissions(_dropdownrepo.TransmissionDropdown());
            carVM.SetExteriorColor(_dropdownrepo.ExteriorColorDropdown());
            carVM.SetInteriorColor(_dropdownrepo.InteriorColorDropdown());
            return(View(carVM));
        }
Esempio n. 5
0
        public ActionResult EditUser(string Id)
        {
            ICarDealerRepository _repo        = RepositoryFactory.Create();
            IDropDown            dropDownRepo = RepositoryFactory.CreateDropDowns();
            UserVM  editVM = new UserVM();
            AppUser user   = _repo.GetUser(Id);

            editVM.LastName  = user.LastName;
            editVM.FirstName = user.FirstName;
            editVM.Email     = user.Email;
            editVM.Role      = user.Role;
            editVM.Password  = user.Password;
            editVM.SetRoles(dropDownRepo.RolesDropDown());
            return(View(editVM));
        }
Esempio n. 6
0
        public ActionResult Edit(int id)
        {
            ICarDealerRepository _repo         = RepositoryFactory.Create();
            IDropDown            _dropdownrepo = RepositoryFactory.CreateDropDowns();
            CarViewModel         carVM         = new CarViewModel();

            carVM.Car = _repo.GetCarById(id);
            carVM.SetMakes(_dropdownrepo.MakeDropdown());
            carVM.SetModels(_dropdownrepo.ModelDropdown());
            carVM.SetTypes(_dropdownrepo.TypeDropdown());
            carVM.SetBodyStyles(_dropdownrepo.BodyStyleDropdown());
            carVM.SetTransmissions(_dropdownrepo.TransmissionDropdown());
            carVM.SetExteriorColor(_dropdownrepo.ExteriorColorDropdown());
            carVM.SetInteriorColor(_dropdownrepo.InteriorColorDropdown());
            return(View(carVM));
        }
Esempio n. 7
0
        internal static void SyncSelectedIndex(this IDropDown instance)
        {
            int selectedItemIndex      = -1;
            IList <DropDownItem> items = instance.Items;
            string value = instance.GetValue <string>(instance.Value);

            if (value.HasValue())
            {
                selectedItemIndex = items.IndexOf(items.FirstOrDefault(item => (item.Value ?? item.Text).ToLowerInvariant() == value.ToLowerInvariant()));
            }

            if (selectedItemIndex == -1)
            {
                instance.Value    = string.Empty;
                selectedItemIndex = items.IndexOf(items.LastOrDefault(item => item.Selected == true));
            }

            if (selectedItemIndex != -1)
            {
                for (int i = 0, length = instance.Items.Count; i < length; i++)
                {
                    instance.Items[i].Selected = false;
                }

                instance.Items[selectedItemIndex].Selected = true;
                instance.SelectedIndex = selectedItemIndex;
            }
            else if (instance.SelectedIndex != -1 && instance.SelectedIndex < instance.Items.Count)
            {
                instance.Items[instance.SelectedIndex].Selected = true;
            }
            else if (instance is DropDownList)
            {
                instance.Items[0].Selected = true;
                instance.SelectedIndex     = 0;
            }
        }