Exemplo n.º 1
0
        public void LookupAttribute_SetsType()
        {
            Type actual = new LookupAttribute(typeof(MvcLookup)).Type;
            Type expected = typeof(MvcLookup);

            Assert.Equal(expected, actual);
        }
        /// <summary>
        /// Deletes a LookupAttribute record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DeleteLookupAttribute(object sender, CommandEventArgs e)
        {
            int             attributeId = int.Parse(e.CommandArgument.ToString());
            LookupAttribute biz         = new LookupAttribute();

            biz.Delete(attributeId);
            BuildEditAttributes();
        }
Exemplo n.º 3
0
        // Two nice to have properties for debugging
        //public string Referenced => Metadata.RelationshipType == RelationshipType.ManyToManyRelationship ? ManyToManyRelationshipMetadata.Entity1LogicalName : OneToManyRelationshipMetadata.ReferencedEntity + "/" + OneToManyRelationshipMetadata.ReferencedAttribute;
        //public string Referencing => Metadata.RelationshipType == RelationshipType.ManyToManyRelationship ? ManyToManyRelationshipMetadata.Entity2LogicalName : OneToManyRelationshipMetadata.ReferencingEntity + "/" + OneToManyRelationshipMetadata.ReferencingAttribute;

        public string Summary(Settings settings)
        {
            if (Metadata is ManyToManyRelationshipMetadata)
            {
                return
                    ($"Entity 1: \"{Parent?.GetNameTechnical(settings.ConstantName, settings)}\" " +
                     $"Entity 2: \"{Child?.GetNameTechnical(settings.ConstantName, settings)}\"");
            }
            return
                ($"Parent: \"{Parent?.GetNameTechnical(settings.ConstantName, settings)}\" " +
                 $"Child: \"{Child?.GetNameTechnical(settings.ConstantName, settings)}\" " +
                 $"Lookup: \"{LookupAttribute?.GetNameTechnical(settings)}\"");
        }
        public void Returns_null_if_no_values_stored()
        {
            {
                string expected = null;
                var    actual   = LookupAttribute.GetValueFromAttribute(TestEnum.ItemWithOneValue, "B");
                Assert.Equal(expected, actual);
            }

            {
                string expected = null;
                var    actual   = LookupAttribute.GetValueFromAttribute(TestEnum.ItemWithoutValues, "C");
                Assert.Equal(expected, actual);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Save's dirty rows (new and existing)
 /// </summary>
 private void Save()
 {
     foreach (GridViewRow row in AttributesGrid.DirtyGridRows)
     {
         BOL.LookupAttribute biz = new LookupAttribute();
         object attributeId      = AttributesGrid.DataKeys[row.RowIndex][BOL.LookupAttribute.AttributeId];
         if (attributeId != null && !string.IsNullOrEmpty(attributeId.ToString()))
         {
             biz.Get(int.Parse(attributeId.ToString()));
         }
         var attributeNameField = row.FindControl("AttributeName") as ICaisisInputControl;
         if (!string.IsNullOrEmpty(attributeNameField.Value))
         {
             biz[BOL.LookupAttribute.AttributeName] = attributeNameField.Value;
             biz.Save();
         }
     }
 }
        /// <summary>
        /// Updates an existing LookupAttribute record, or inserts new record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UpdateAttribute(object sender, EventArgs e)
        {
            CaisisTextBox attributeNameField = sender as CaisisTextBox;
            CaisisHidden  attributeIdField   = attributeNameField.NamingContainer.FindControl("AttributeId") as CaisisHidden;

            if (!string.IsNullOrEmpty(attributeNameField.Value))
            {
                // don't inesrt empty attribut names
                LookupAttribute biz = new LookupAttribute();
                // determine if updating or inserting
                if (attributeIdField != null && !string.IsNullOrEmpty(attributeIdField.Value))
                {
                    biz.Get(int.Parse(attributeIdField.Value));
                }
                biz[LookupAttribute.AttributeName] = attributeNameField.Value;
                biz.Save();
            }
        }
        public void Can_get_stored_values()
        {
            {
                var expected = "1";
                var actual   = LookupAttribute.GetValueFromAttribute(TestEnum.ItemWithOneValue, "A");
                Assert.Equal(expected, actual);
            }

            {
                var expected = "1";
                var actual   = LookupAttribute.GetValueFromAttribute(TestEnum.ItemWithTwoValues, "A");
                Assert.Equal(expected, actual);
            }

            {
                var expected = "2";
                var actual   = LookupAttribute.GetValueFromAttribute(TestEnum.ItemWithTwoValues, "B");
                Assert.Equal(expected, actual);
            }
        }
Exemplo n.º 8
0
        protected override void Execute(CodeActivityContext eContext)
        {
            var lookup = LookupAttribute.Get(eContext);
            var orgurl = OrgUrl.Get(eContext);
            var context = eContext.GetExtension<IWorkflowContext>();
            var serviceFactory = eContext.GetExtension<IOrganizationServiceFactory>();
            var service = serviceFactory.CreateOrganizationService(context.UserId);

            var reference = GetReference(service, lookup, new EntityReference(context.PrimaryEntityName, context.PrimaryEntityId));
            
            // Update Reference Information
            if (reference == null) return;
            ID.Set(eContext, reference.Id.ToString());
            LogicalName.Set(eContext, reference.LogicalName);

            // Update URL Information
            if (string.IsNullOrWhiteSpace(orgurl)) return;

            var url = CreateUrl(orgurl, reference);
            URL.Set(eContext, url);
            HtmlLink.Set(eContext, CreateHtmlLink(service, reference, url, LinkText.Get(eContext)));
        }