示例#1
0
        public bool Delete(RS.ResourceStructure resoureStruc)
        {
            Contract.Requires(resoureStruc != null);
            Contract.Requires(resoureStruc.Id >= 0);

            bool deleted = false;

            if (resoureStruc.ResourceAttributeUsages != null)
            {
                using (var rsaManager = new ResourceStructureAttributeManager())
                {
                    deleted = rsaManager.DeleteUsagesByRSId(resoureStruc.Id);
                }
            }
            else
            {
                deleted = true;
            }

            if (deleted)
            {
                using (IUnitOfWork uow = this.GetUnitOfWork())
                {
                    IRepository <RS.ResourceStructure> repoStruc = uow.GetRepository <RS.ResourceStructure>();

                    resoureStruc = repoStruc.Reload(resoureStruc);
                    repoStruc.Delete(resoureStruc);

                    uow.Commit();
                }
                return(true);
            }

            return(false);
        }
示例#2
0
        public List <EntityStoreItem> GetEntities(int skip, int take)
        {
            bool withPaging = (take >= 0);

            using (var uow = this.GetUnitOfWork())
                using (ResourceStructureAttributeManager resourceStructureAttributeManager = new ResourceStructureAttributeManager())
                {
                    if (withPaging)
                    {
                        return(resourceStructureAttributeManager.GetAllResourceStructureAttributes().Select(r => new EntityStoreItem()
                        {
                            Id = r.Id, Title = r.Name
                        }).Skip(skip).Take(take).ToList());
                    }
                    else
                    {
                        return(resourceStructureAttributeManager.GetAllResourceStructureAttributes().Select(r => new EntityStoreItem()
                        {
                            Id = r.Id, Title = r.Name
                        }).ToList());
                    }
                }
        }