Beispiel #1
0
        public IHttpActionResult GetRegisterItemByName(string registerName, string subregisters = null)
        {
            var    path     = RegisterUrls.GetPath(registerName, subregisters);
            string systemId = RegisterUrls.GetSystemIdFromPath(registerName + "/" + subregisters);
            string format   = RegisterUrls.GetFileExtension(registerName + "/" + subregisters);

            path = RegisterUrls.RemoveExtension(path);

            var mediatype = GetFormattingForMediaType(format);

            var register = _registerService.GetRegisterByPath(path);

            if (register == null)
            {
                var currentVersion = ConvertCurrentAndVersions(null, registerName, RegisterUrls.GetItemFromPath(subregisters));

                if (currentVersion != null)
                {
                    return(Content(HttpStatusCode.OK, currentVersion, mediatype.Formatter, mediatype.MediaTypeHeader));
                }

                return(NotFound());
            }

            if (!string.IsNullOrEmpty(systemId))
            {
                var currentVersion = ConvertCurrentAndVersions(register, systemId);
                return(Content(HttpStatusCode.OK, currentVersion, mediatype.Formatter, mediatype.MediaTypeHeader));
            }
            else
            {
                var result = (ConvertRegisterAndNextLevel(register));
                return(Content(HttpStatusCode.OK, result, mediatype.Formatter, mediatype.MediaTypeHeader));
            }
        }