private void FormatLocation(ContentHead content)
        {
            content.Name          = content.Name.Trim();
            content.CanonicalName = _cmsService.CanonicalName(content.Name);
            if (!content.Location.EndsWith("/"))
            {
                content.Location = content.Location + "/";
            }
            content.Location = content.Location.ToLower();


            ContentHead contentWithSameUrl = _cmsService.GetContentHeadByUrlAndKind(content.Location + content.CanonicalName, null, false);

            if (contentWithSameUrl == null || contentWithSameUrl.ContentUId == content.ContentUId)
            {
                return;
            }

            // if already exists a different content with the same url and browsable, throws an error
            ContentKind ckind = _cmsService.GetContentKind(content.Kind);

            if (ckind.Browsable.HasValue && (bool)ckind.Browsable)
            {
                content.CanonicalName = MakeCanonicalNameUnique(content);
                contentWithSameUrl    = _cmsService.GetContentHeadByUrlAndKind(content.Location + content.CanonicalName, null, false);
                if (contentWithSameUrl != null && contentWithSameUrl.ContentUId != content.ContentUId)
                {
                    throw new Exception("Content with same name already exists");
                }
            }

            return;
        }
Example #2
0
 public ContentKind Get(string id)
 {
     return(_cmsService.GetContentKind(id, true));
 }