public IActionResult EditNummer(int id)
        {
            Nummer nummerFromDb       = _context.Nummers.Include(genre => genre.NummerGenres).Include(artiest => artiest.NummerArtiests).FirstOrDefault(x => x.Id == id);
            NummerEditViewModel model = new NummerEditViewModel()
            {
                Id        = nummerFromDb.Id,
                Speelduur = nummerFromDb.Speeltijd,
                Titel     = nummerFromDb.Naam
            };

            foreach (var item in _context.Artiesten)
            {
                SelectListItem listItem = new SelectListItem(item.Naam, item.Id.ToString());
                model.Artisten.Add(listItem);
                if (_context.NummerArtiesten.Where(x => x.NummerId == nummerFromDb.Id).FirstOrDefault(y => y.ArtiestId == item.Id) != null)
                {
                    listItem.Selected = true;
                }
            }
            foreach (var item in _context.GenreNummers)
            {
                CheckboxViewModel checkbox = new CheckboxViewModel()
                {
                    Id = item.Id, Naam = item.Naam
                };
                model.Genres.Add(checkbox);
                if (_context.NummerGenres.Where(x => x.NummerId == nummerFromDb.Id).FirstOrDefault(y => y.GenreId == item.Id) != null)
                {
                    checkbox.Checked = true;
                }
            }
            return(View(model));
        }
Esempio n. 2
0
 // POST api/values
 public HttpResponseMessage Post(CheckboxViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(new HttpResponseMessage(HttpStatusCode.BadRequest));
     }
     return(new HttpResponseMessage(HttpStatusCode.OK));
 }
        public CheckboxListCodePage()
        {
            ToolbarItem reload = new ToolbarItem()
            {
                Text = "Reload"
            };

            reload.Clicked += (sender, e) =>
            {
                controls.Clear();
                var c = GetControls(30);
                foreach (var item in c)
                {
                    controls.Add(item);
                }
            };

            ToolbarItems.Add(reload);

            BindingContext = new CheckboxViewModel();
            var list = new ListView();

            //list.SetBinding(ListView.ItemsSourceProperty, "Checkboxes");
            var template = new DataTemplate(typeof(ControlCell <Checkbox, Switch>));

            list.ItemTemplate = template;

            controls           = new ObservableCollection <ControlWrapper>(GetControls(30));
            list.ItemsSource   = controls;
            list.ItemSelected += (sender, e) =>
            {
                if (list.SelectedItem != null)
                {
                    var c = list.SelectedItem as ControlWrapper;
                    c.IsVisible       = !c.IsVisible;
                    list.SelectedItem = null;
                }
            };

            Content = list;
        }
Esempio n. 4
0
        public ActionResult Permisos(string id)
        {
            RoleBL       oBL           = new RoleBL();
            PermissionBL oPermissionBL = new PermissionBL();
            int          pIntID        = 0;

            int.TryParse(id, out pIntID);
            RoleViewModel pRoleViewModel = oBL.ObtenerRole(pIntID);

            ViewBag.NameRole = pRoleViewModel.role;
            ViewBag.role_id  = pRoleViewModel.role_id;

            var all = oPermissionBL.ObtenerListaPermisos();

            List <CheckboxViewModel> permisos = new List <CheckboxViewModel>();
            var permission_enabled            = oPermissionBL.ObtenerListaPermisos(pIntID);

            foreach (var permiso in all)
            {
                CheckboxViewModel oCheckboxViewModel = new CheckboxViewModel();
                oCheckboxViewModel.Name  = permiso.title;
                oCheckboxViewModel.Value = permiso.id_permission.ToString();
                if (permission_enabled.Contains(permiso.id_permission))
                {
                    oCheckboxViewModel.Checked = "checked";
                }
                else
                {
                    oCheckboxViewModel.Checked = String.Empty;
                }

                permisos.Add(oCheckboxViewModel);
            }

            ViewBag.permisos = permisos;

            return(View(pRoleViewModel));
        }
Esempio n. 5
0
        public CheckboxPage()
        {
            InitializeComponent();

            BindingContext = new CheckboxViewModel();
        }
 // POST api/values
 public HttpResponseMessage Post(CheckboxViewModel model)
 {
     if (!ModelState.IsValid)
         return new HttpResponseMessage(HttpStatusCode.BadRequest);
     return new HttpResponseMessage(HttpStatusCode.OK);
 }