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)); } }
public async Task <IFormResult <ContentType> > CreateItem(ContentType contentType) { ParseContentTypeField(contentType); contentType = _contentTypeRepository.CreateContentType(contentType); if (contentType == null) { return new FormResult <ContentType>() { IsSucceeded = false, ErrorMessage = "Unable to create the ContentType" } } ; var result = new FormResult <ContentType>(contentType) { IsSucceeded = true, SuccessMessage = "ContentType has been created" }; return(await Task.FromResult(result)); }