public int SaveComponentsToRole(IComponentsToRoleDb componentsToRoleDb, int? transactionNumber = null)
        {
            if (componentsToRoleDb.InstanceId != _instanceId)
                throw new Exception("Attempt to save ComponentsToRole with wrong InstanceId");

            ComponentsToRole record;
            var recordOld = new ComponentsToRole();
            if (componentsToRoleDb.ComponentToRoleId == 0)
            {
                record = new ComponentsToRole();
                Context.AddToComponentsToRoles(record);
            }
            else
            {
                record = Context.ComponentsToRoles.Where(r => r.ComponentToRoleId == componentsToRoleDb.ComponentToRoleId).First();
                ReflectionHelper.CopyAllProperties(record, recordOld);
            }

            record.InstanceId = _instanceId;
            record.ComponentId = componentsToRoleDb.ComponentId;
            record.RoleId = componentsToRoleDb.RoleId;
            record.AccessLevel = componentsToRoleDb.AccessLevel;

            Context.SaveChanges();
            if (componentsToRoleDb.ComponentToRoleId == 0)
            {
                componentsToRoleDb.ComponentToRoleId = record.ComponentToRoleId;
                LogToDb(UserId, "ComponentsToRoles", record.ComponentToRoleId, "I", XmlHelper.GetObjectXml(record), transactionNumber);
            }
            else
            {
                LogToDb(UserId, "ComponentsToRoles", record.ComponentToRoleId, "U", XmlHelper.GetDifferenceXml(recordOld, record), transactionNumber);
            }

            return componentsToRoleDb.ComponentToRoleId;
        }
 public void AddToComponentsToRoles(ComponentsToRole record)
 {
     _context.AddToComponentsToRoles(record);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new ComponentsToRole object.
 /// </summary>
 /// <param name="componentToRoleId">Initial value of the ComponentToRoleId property.</param>
 /// <param name="instanceId">Initial value of the InstanceId property.</param>
 /// <param name="componentId">Initial value of the ComponentId property.</param>
 /// <param name="roleId">Initial value of the RoleId property.</param>
 /// <param name="accessLevel">Initial value of the AccessLevel property.</param>
 public static ComponentsToRole CreateComponentsToRole(global::System.Int32 componentToRoleId, global::System.Int32 instanceId, global::System.Int32 componentId, global::System.Int32 roleId, global::System.Int32 accessLevel)
 {
     ComponentsToRole componentsToRole = new ComponentsToRole();
     componentsToRole.ComponentToRoleId = componentToRoleId;
     componentsToRole.InstanceId = instanceId;
     componentsToRole.ComponentId = componentId;
     componentsToRole.RoleId = roleId;
     componentsToRole.AccessLevel = accessLevel;
     return componentsToRole;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ComponentsToRoles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToComponentsToRoles(ComponentsToRole componentsToRole)
 {
     base.AddObject("ComponentsToRoles", componentsToRole);
 }