From 7206edbdec514828cbde81156b86495313c3f658 Mon Sep 17 00:00:00 2001 From: mumana Date: Fri, 15 Jun 2018 15:36:31 +0000 Subject: [PATCH] git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C53 --- .../Sinort/PantallasDAL.cs | 21 ++++++++++++++++++- .../AYA.SlnSynorModel.DAL/Sinort/RolesDAL.cs | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/PantallasDAL.cs b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/PantallasDAL.cs index 2bbe91f2c..bf978cea3 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/PantallasDAL.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/PantallasDAL.cs @@ -43,7 +43,26 @@ namespace AYA.SlnSinortModel.DAL.Sinort { using (SinortContex db = new SinortContex()) { - registros = db.RolesPantallas.Where(r => r.IdRol.ToString() == model.codigo).Include(p => p.Pantallas).AsNoTracking().ToList(); + + if (model == null && !string.IsNullOrWhiteSpace(model.codigo)) + { + if (!db.RolesPantallas.Any(r => r.IdRol.ToString() == model.codigo)) + { + var ListaPantallas = db.Pantallas.ToList(); + var dal = new RolesDAL(); + + foreach (var pantalla in ListaPantallas) + dal.InsertarActualizarRolesPantallas(new RolesPantallas() + { + IdRol = Convert.ToInt32(model.codigo), + IdPantalla = pantalla.IdPantalla, + Estado = false + }); + } + + registros = db.RolesPantallas.Where(r => r.IdRol.ToString() == model.codigo).Include(p => p.Pantallas).AsNoTracking().ToList(); + } + } } catch (Exception ex) diff --git a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/RolesDAL.cs b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/RolesDAL.cs index 627c3551b..ef0c1caf6 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/RolesDAL.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/RolesDAL.cs @@ -134,7 +134,7 @@ namespace AYA.SlnSinortModel.DAL.Sinort using (SinortContex Conn = new SinortContex()) { - Actual = Conn.RolesPantallas.Where(x => x.IdRolesPantallas == model.IdRolesPantallas ).FirstOrDefault(); + Actual = Conn.RolesPantallas.FirstOrDefault(x => x.IdRolesPantallas == model.IdRolesPantallas ); if (Actual == null) { int? Next_id = Conn.RolesPantallas.Max(t => (int?)t.IdRolesPantallas);