示例#1
0
        public override IMember GetByVersion(Guid versionId)
        {
            var sql = GetBaseQuery(false);

            sql.Where("cmsContentVersion.VersionId = @VersionId", new { VersionId = versionId });
            sql.OrderByDescending <ContentVersionDto>(x => x.VersionDate);

            var dto = Database.Fetch <MemberDto, ContentVersionDto, ContentDto, NodeDto>(sql).FirstOrDefault();

            if (dto == null)
            {
                return(null);
            }

            var memberType = _memberTypeRepository.Get(dto.ContentVersionDto.ContentDto.ContentTypeId);

            var factory = new MemberFactory(memberType, NodeObjectTypeId, dto.NodeId);
            var media   = factory.BuildEntity(dto);

            var properties = GetPropertyCollection(sql, new[] { new DocumentDefinition(dto.NodeId, dto.ContentVersionDto.VersionId, media.UpdateDate, media.CreateDate, memberType) });

            media.Properties = properties[dto.NodeId];

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            ((Entity)media).ResetDirtyProperties(false);
            return(media);
        }
        public ActionResult Create()
        {
            Member memberDetails = new Member();

            ViewBag.MemberType = memberTypeRepository.Get();
            ViewBag.Branch     = branchRepository.Get();
            return(View(memberDetails));
        }
        private IEnumerable <IMember> MapDtosToContent(List <MemberDto> dtos, bool withCache = false)
        {
            var temps        = new List <TempContent <Member> >();
            var contentTypes = new Dictionary <int, IMemberType?>();
            var content      = new Member[dtos.Count];

            for (var i = 0; i < dtos.Count; i++)
            {
                MemberDto dto = dtos[i];

                if (withCache)
                {
                    // if the cache contains the (proper version of the) item, use it
                    IMember?cached =
                        IsolatedCache.GetCacheItem <IMember>(RepositoryCacheKeys.GetKey <IMember, int>(dto.NodeId));
                    if (cached != null && cached.VersionId == dto.ContentVersionDto.Id)
                    {
                        content[i] = (Member)cached;
                        continue;
                    }
                }

                // else, need to build it

                // get the content type - the repository is full cache *but* still deep-clones
                // whatever comes out of it, so use our own local index here to avoid this
                var contentTypeId = dto.ContentDto.ContentTypeId;
                if (contentTypes.TryGetValue(contentTypeId, out IMemberType? contentType) == false)
                {
                    contentTypes[contentTypeId] = contentType = _memberTypeRepository.Get(contentTypeId);
                }

                Member c = content[i] = ContentBaseFactory.BuildEntity(dto, contentType);

                // need properties
                var versionId = dto.ContentVersionDto.Id;
                temps.Add(new TempContent <Member>(dto.NodeId, versionId, 0, contentType, c));
            }

            // load all properties for all documents from database in 1 query - indexed by version id
            IDictionary <int, PropertyCollection> properties = GetPropertyCollections(temps);

            // assign properties
            foreach (TempContent <Member> temp in temps)
            {
                if (temp.Content is not null)
                {
                    temp.Content.Properties = properties[temp.VersionId];

                    // reset dirty initial properties (U4-1946)
                    temp.Content.ResetDirtyProperties(false);
                }
            }

            return(content);
        }
示例#4
0
 public IEnumerable <MemberType> GetAllMemberTypes()
 {
     try
     {
         return(_memberTypeRepository.Get().ToList());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
        private IMember BuildFromDto(List <MemberReadOnlyDto> dtos)
        {
            if (dtos == null || dtos.Any() == false)
            {
                return(null);
            }
            var dto = dtos.First();

            var memberTypes = new Dictionary <string, IMemberType>
            {
                {
                    dto.ContentTypeAlias,
                    _memberTypeRepository.Get(dto.ContentTypeId)
                }
            };

            var factory = new MemberReadOnlyFactory(memberTypes);
            var member  = factory.BuildEntity(dto);

            return(member);
        }
        public ActionResult List()
        {
            List <MemberType> memberTypeList = memberTypeRepository.Get();

            return(View(memberTypeList));
        }