Пример #1
0
        public Element Get(string name, string category, string culture)
        {
            var entity = new LabelEntity(SiteName, name, "", category);

            return(CloudTableHelper.GetTableServiceContext().CreateQuery <LabelEntity>(LabelTable)
                   .Where(it => it.PartitionKey == entity.SiteName && it.RowKey == entity.RowKey)
                   .ToArray()
                   .Select(it => it.ToElement())
                   .FirstOrDefault());
        }
Пример #2
0
        public bool Remove(Element element)
        {
            var entity         = new LabelEntity(SiteName, element);
            var serviceContext = CloudTableHelper.GetTableServiceContext();

            entity = serviceContext.CreateQuery <LabelEntity>(LabelTable)
                     .Where(it => it.PartitionKey == SiteName && it.RowKey == entity.RowKey)
                     .FirstOrDefault();
            if (entity != null)
            {
                serviceContext.DeleteObject(entity);
                serviceContext.SaveChangesWithRetries();
            }
            return(true);
        }
Пример #3
0
        private void InsertOrUpdateLabel(Element @new, Element old)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = new LabelEntity(SiteName, @new);

            if (Get(old.Name, old.Category, old.Culture) == null)
            {
                if (!string.IsNullOrEmpty(@new.Category))
                {
                    AddCategory(@new.Category, @new.Culture);
                }
                serviceContext.AddObject(LabelTable, entity);
            }
            else
            {
                serviceContext.AttachTo(LabelTable, entity, "*");
                serviceContext.UpdateObject(entity);
            }
            serviceContext.SaveChangesWithRetries();
        }
Пример #4
0
 public Element Get(string name, string category, string culture)
 {
     var entity = new LabelEntity(SiteName, name, "", category);
     return CloudTableHelper.GetTableServiceContext().CreateQuery<LabelEntity>(LabelTable)
            .Where(it => it.PartitionKey == entity.SiteName && it.RowKey == entity.RowKey)
            .ToArray()
            .Select(it => it.ToElement())
            .FirstOrDefault();
 }
Пример #5
0
 private void InsertOrUpdateLabel(Element @new, Element old)
 {
     var serviceContext = CloudTableHelper.GetTableServiceContext();
     var entity = new LabelEntity(SiteName, @new);
     if (Get(old.Name, old.Category, old.Culture) == null)
     {
         if (!string.IsNullOrEmpty(@new.Category))
         {
             AddCategory(@new.Category, @new.Culture);
         }
         serviceContext.AddObject(LabelTable, entity);
     }
     else
     {
         serviceContext.AttachTo(LabelTable, entity, "*");
         serviceContext.UpdateObject(entity);
     }
     serviceContext.SaveChangesWithRetries();
 }
Пример #6
0
 public bool Remove(Element element)
 {
     var entity = new LabelEntity(SiteName, element);
     var serviceContext = CloudTableHelper.GetTableServiceContext();
     entity = serviceContext.CreateQuery<LabelEntity>(LabelTable)
            .Where(it => it.PartitionKey == SiteName && it.RowKey == entity.RowKey)
            .FirstOrDefault();
     if (entity != null)
     {
         serviceContext.DeleteObject(entity);
         serviceContext.SaveChangesWithRetries();
     }
     return true;
 }