Exemple #1
0
        public void Add(int fileDoId, TagDO tag)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var tagRepository     = uow.TagRepository;
                var fileTagRepository = uow.FileTagsRepository;
                var fileTag           = new FileTags()
                {
                    FileDoId = fileDoId
                };

                var dbTag = GetByKey(tag.Key);
                if (dbTag == null)
                {
                    tagRepository.Add(tag);
                    uow.SaveChanges();

                    dbTag = tagRepository.GetByKey(tag.Key);
                }

                fileTag.TagId = dbTag.Id;

                fileTagRepository.Add(fileTag);
                uow.SaveChanges();
            }
        }
Exemple #2
0
        public TagDO GetByKey(string key)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                TagDO tag    = null;
                var   result = uow.TagRepository.FindOne(x => x.Key == key);
                if (!object.Equals(result, default(TagDO)))
                {
                    tag = result;
                }

                return(tag);
            }
        }
        private TagDO CreateTagDo(int id, string key, string value)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                TagDO tagDo = new TagDO()
                {
                    Id    = id,
                    Key   = key,
                    Value = value
                };

                uow.TagRepository.Add(tagDo);
                uow.SaveChanges();

                return(tagDo);
            }
        }
Exemple #4
0
 public IList <FileDO> GetFiles(TagDO tag)
 {
     return(GetFiles(tag.Id));
 }