Inheritance: System.Data.Objects.DataClasses.EntityObject
        public void crear_rol(string descripcion, List<string> licences, long centro)
        {
            try
            {
                DataAccess.role rolNuevo = new role();//creacion de rol
                rolNuevo.descripcion = descripcion;
                rolNuevo.centro = centro;
                entidad.roles.AddObject(rolNuevo);//agregar el rol nuevo al contexto
                entidad.SaveChanges();//commit1

                foreach (string permisoCod in licences)
                {
                    var permisoQuery = from per in entidad.permisos
                                       where per.id == permisoCod
                                       select per;

                    DataAccess.permiso permisoTMP = permisoQuery.First();
                    rolNuevo.permisos.Add(permisoTMP);//ya que el permisos en roles es un collection, agregamos cada permiso utilizando el id que viene en la lista
                }
                entidad.SaveChanges();//commit2 --> 2 commits por el autoincrement del rol.id!!
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString() + " --Security.cs / crear_rol()");
            }
        }
Beispiel #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the roles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToroles(role role)
 {
     base.AddObject("roles", role);
 }
Beispiel #3
0
 /// <summary>
 /// Create a new role object.
 /// </summary>
 /// <param name="descripcion">Initial value of the descripcion property.</param>
 /// <param name="id">Initial value of the id property.</param>
 public static role Createrole(global::System.String descripcion, global::System.Int64 id)
 {
     role role = new role();
     role.descripcion = descripcion;
     role.id = id;
     return role;
 }