Exemple #1
0
        public IActionResult CreateContentType([FromBody] ContentType contentType)
        {
            try
            {
                if (contentType == null || string.IsNullOrEmpty(contentType.Name))
                {
                    return(BadRequest("Invalid parameter"));
                }

                if (_contentTypeRepository.GetContentType(contentType.Name) != null)
                {
                    return(BadRequest("Content type already exist"));
                }

                var result = _contentTypeRepository.CreateContentType(contentType);

                if (result != null)
                {
                    return(Ok(result));
                }
                return(NotFound());
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("Error occured while creating layout type"), ex);
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
        }
Exemple #2
0
        public async Task <ContentType> GetItem(string contentTypeId)
        {
            var result = _contentTypeRepository.GetContentType(Guid.Parse(contentTypeId));

            return(await Task.FromResult(result));
        }