private void CheckScreen_Checked(object sender, System.Windows.RoutedEventArgs e) { CheckBox check = (CheckBox)sender; Pantallas currentScreen = check.DataContext as Pantallas; if (currentUser != null) { if ((bool)check.IsChecked) { long screenToAdd = currentUser.PantallasUsuario.Where(x => x.idPantalla.Equals(currentScreen.idPantalla)).Select(x => x.idPantallasUsuario).SingleOrDefault(); if (screenToAdd == 0) { PantallasUsuario pantalla = new PantallasUsuario { idPantalla = currentScreen.idPantalla, idUsuario = currentUser.idUsuario, }; currentUser.PantallasUsuario.Add(pantalla); } } else { long screenToRemove = currentUser.PantallasUsuario.Where(x => x.idPantalla.Equals(currentScreen.idPantalla)).Select(x => x.idPantallasUsuario).SingleOrDefault(); if (screenToRemove != 0) { _permissionsPresenter.DeleteImpuestoProductoById(screenToRemove); } currentUser.PantallasUsuario = currentUser.PantallasUsuario.Where(x => !x.idPantalla.Equals(currentScreen.idPantalla)).ToList(); } } }
private void CheckScreen_Loaded(object sender, System.Windows.RoutedEventArgs e) { CheckBox check = (CheckBox)sender; Pantallas pantalla = check.DataContext as Pantallas; if (pantalla != null) { //meter procedimiento PantallasUsuario usuarioPantalla = currentUser.PantallasUsuario.Where(x => x.idPantalla.Equals(pantalla.idPantalla)).FirstOrDefault(); if (usuarioPantalla != null) { check.IsChecked = true; } else { check.IsChecked = false; } } }
public IActionResult DeletePantallaUsuario(long idPantallaUsuario) { try { PantallasUsuario screenToRemove = PosUoW.PantallasUsuarioRepository.GetById(x => x.idPantallasUsuario.Equals(idPantallaUsuario)); if (screenToRemove != null) { PosUoW.PantallasUsuarioRepository.Remove(screenToRemove); PosUoW.Save(); return(Ok()); } else { return(NotFound()); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }