public SecUsuario Map(SecUsuario usuario, SecRol rol) { // Terminating call. Since we can return null from this function // we need to be ready for PetaPoco to callback later with null // parameters if (usuario == null) { return(current); } // Is this the same usuario as the current one we're processing if (current != null && current.Id == usuario.Id) { // Yes, just add this tag to the current usuario's collection of tags current.Roles.Add(rol); // Return null to indicate we're not done with this usuario yet return(null); } // This is a different author to the current one, or this is the // first time through and we don't have an author yet // Save the current author var prev = current; // Setup the new current author current = usuario; if (rol.Id != 0) { current.Roles.Add(rol); } //current.Tags = new List<Tag>(); //current.posts.Add(p); // Return the now populated previous author (or null if first time through) return(prev); }
public SecRol Map(SecRol rol, SecUsuario usuario) { // Terminating call. Since we can return null from this function // we need to be ready for PetaPoco to callback later with null // parameters if (rol == null) { return(current); } // Is this the same tag as the current one we're processing if (current != null && current.Id == rol.Id) { // Yes, just add this usuario to the current tag's collection of articles if (usuario != null) { current.Usuarios.Add(usuario); } // Return null to indicate we're not done with this tag yet return(null); } // This is a different tag to the current one, or this is the // first time through and we don't have an tag yet // Save the current tag var prev = current; // Setup the new current tag current = rol; if (usuario != null && usuario.Id != int.MinValue) { current.Usuarios.Add(usuario); } return(prev); }
public bool UpdateRolPermiso(SecRol rol) { using (var scope = _database.GetTransaction()) { _database.Update(rol, new string[] { "nombre", "descripcion", "activo" }); _database.Execute("delete from SecRolGrupoPerfil where idsecrol=@0", rol.Id); foreach (var permiso in rol.Permisos) { _database.Insert("SecRolGrupoPerfil", "id", true, new SecPermiso() { Idsecrol = permiso.Idsecrol, Idsecaplicacion = permiso.Idsecaplicacion, Idsecaccion = permiso.Idsecaccion, Idsecaccion2 = permiso.Idsecaccion2 } ); } scope.Complete(); } return(true); }
public bool Insert(SecRol rol) { _database.Insert("SecRol", "id", true, rol); return(true); }
public bool Update(SecRol rol) { _database.Update(rol, new string[] { "nombre", "descripcion", "activo" }); return(true); }