Example #1
0
        private static Guid CreateFacilityWithTags(TagManager manager, out Tag newTag)
        {
            var id = Guid.NewGuid();
            var f  = new Facility
            {
                Id   = id,
                Tags =
                    new List <Tag>
                {
                    new Tag
                    {
                        Id       = Guid.NewGuid(),
                        Category = new TagCategory {
                            Color = KnownColor.Transparent, Name = "Default"
                        },
                        CreateDate = DateTime.UtcNow,
                        Value      = id.ToString(),
                        Type       = TagType.Facility
                    }
                }
            };

            using (var session = DocumentStoreLocator.ResolveOrRoot(CommonConfiguration.CoreDatabaseRoute))
            {
                session.Store(f);
                session.SaveChanges();
            }

            var tcm      = new TagCategoryManager();
            var category = tcm.GetNotDefault().First();

            var tags = f.Tags;

            newTag = new Tag
            {
                Id         = Guid.NewGuid(),
                Category   = category,
                CreateDate = DateTime.UtcNow,
                Value      = "aValue",
                Attribute  = "Validation",
                Type       = TagType.Facility
            };
            tags.Add(newTag);

            manager.AssignTags <Facility>(id, tags, true);
            return(id);
        }