Exemplo n.º 1
0
        private void RefreshObjectTypeDropDown()
        {
            using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext()))
            {
                NavigationProperty property = dataAccess.GetNavigationProperty(this.Page.Cache
                                                                               , typeName, _predicateDropDownList.SelectedItem.Text);

                string resTypeName = string.Empty;

                if (property.Direction == AssociationEndType.Subject)
                {
                    resTypeName = property.Association.ObjectNavigationProperty.Parent.Name;
                }
                else if (property.Direction == AssociationEndType.Object)
                {
                    resTypeName = property.Association.SubjectNavigationProperty.Parent.Name;
                }
                List <ResourceType> resourceTypeList = dataAccess.GetResourceTypeList
                                                           (resTypeName)
                                                       .OrderBy(res => res.Name).ToList();

                _objectTypeDropDownList.DataSource = resourceTypeList;
                _objectTypeDropDownList.DataBind();
                FilterCriteriaGrid.EntityType = _objectTypeDropDownList.SelectedValue;
            }
        }
Exemplo n.º 2
0
        private NavigationProperty GetNavigationProperty(Resource resource)
        {
            NavigationProperty navProperty = null;

            if (resource != null)
            {
                using (ResourceDataAccess dataAccess = new ResourceDataAccess(this.CreateContext()))
                {
                    navProperty = dataAccess.GetNavigationProperty(this.Page.Cache, resource.GetType().Name, _FilesProperty);
                }
            }

            return(navProperty);
        }
Exemplo n.º 3
0
        private NavigationProperty GetNavigationProperty(Resource resource)
        {
            NavigationProperty navProperty = null;

            if (!string.IsNullOrEmpty(NavigationPropertyName) && resource != null)
            {
                using (ResourceDataAccess dataAccess = new ResourceDataAccess(this.CreateContext()))
                {
                    navProperty = dataAccess.GetNavigationProperty(this.Page.Cache,
                                                                   resource.GetType().Name, NavigationPropertyName);
                }
            }

            return(navProperty);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns list of items to be used as a destination list.
        /// </summary>
        /// <returns>List of destination items.</returns>
        protected override IList GetDestinationItems()
        {
            IList resources = null;

            using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext()))
            {
                NavigationProperty property = dataAccess.GetNavigationProperty(this.Page.Cache,
                                                                               typeName, _predicateDropDownList.SelectedItem.Text);

                if (IsSecurityAwareControl)
                {
                    if (AuthenticatedToken != null)
                    {
                        resources = dataAccess.GetRelatedResources(SubjectItemId, property, AuthenticatedToken, Constants.PermissionRequiredForAssociation);
                    }
                }
                else
                {
                    resources = dataAccess.GetRelatedResources(SubjectItemId, property, null, Constants.PermissionRequiredForAssociation);
                }
            }
            return(resources);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Saves associations for the subject entity.
        /// </summary>
        /// <returns>A Boolean value indicating success of operation.</returns>
        public override bool SaveAssociation()
        {
            bool result = false;

            using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext()))
            {
                AuthorizeResourcesBeforeSave <Resource>(dataAccess);

                NavigationProperty property = dataAccess.GetNavigationProperty(this.Page.Cache
                                                                               , typeName, _predicateDropDownList.SelectedItem.Text);

                if (property != null &&
                    dataAccess.ValidateAssociation <Resource>(SubjectItemId, property,
                                                              DestinationList as List <Resource>))
                {
                    result = dataAccess.SaveResourceToResourceAssociation <Resource>
                                 (SubjectItemId, property, DestinationList as List <Resource>,
                                 AuthenticatedToken, Constants.PermissionRequiredForAssociation);
                }
            }

            return(result);
        }