Exemplo n.º 1
0
        public string ProcessTags(NopCommerceDataReader dataReader, NopImportContext nopImportContext)
        {
            HashSet <TagData> tagDatas = dataReader.GetTags();
            var site = _session.Get <Site>(_site.Id);
            Dictionary <string, Tag> tags = _session.QueryOver <Tag>()
                                            .List().ToDictionary(x => x.Name);

            _session.Transact(session =>
            {
                foreach (TagData tagData in tagDatas)
                {
                    string name = tagData.Name.Trim();
                    Tag tag;
                    if (!tags.ContainsKey(name))
                    {
                        tag = new Tag {
                            Name = name
                        };
                        tag.AssignBaseProperties(site);
                        session.Insert(tag);
                    }
                    else
                    {
                        tag = tags[name];
                    }
                    nopImportContext.AddEntry(tagData.Id, tag);
                }
            });
            return(string.Format("{0} tags processed", tagDatas.Count));
        }
Exemplo n.º 2
0
 public string ProcessTags(NopCommerceDataReader dataReader, NopImportContext nopImportContext)
 {
     HashSet<TagData> tagDatas = dataReader.GetTags();
     foreach (TagData tagData in tagDatas)
     {
         string name = tagData.Name.Trim();
         Tag tag =
             _session.QueryOver<Tag>()
                 .Where(b => b.Name.IsInsensitiveLike(name, MatchMode.Exact))
                 .List().FirstOrDefault();
         if (tag == null)
         {
             tag = new Tag { Name = name };
             _session.Transact(session => session.Save(tag));
         }
         nopImportContext.AddEntry(tagData.Id, tag);
     }
     return string.Format("{0} tags processed", tagDatas.Count);
 }
Exemplo n.º 3
0
        public string ProcessTags(NopCommerceDataReader dataReader, NopImportContext nopImportContext)
        {
            HashSet <TagData> tagDatas = dataReader.GetTags();

            foreach (TagData tagData in tagDatas)
            {
                string name = tagData.Name.Trim();
                Tag    tag  =
                    _session.QueryOver <Tag>()
                    .Where(b => b.Name.IsInsensitiveLike(name, MatchMode.Exact))
                    .List().FirstOrDefault();
                if (tag == null)
                {
                    tag = new Tag {
                        Name = name
                    };
                    _session.Transact(session => session.Save(tag));
                }
                nopImportContext.AddEntry(tagData.Id, tag);
            }
            return(string.Format("{0} tags processed", tagDatas.Count));
        }