Beispiel #1
0
        public async Task <IActionResult> CreateKeyword([FromBody] AddKeywordDTO addKeywordResource)
        {
            Keyword keywordModel = _mapper.Map <AddKeywordDTO, Keyword>(addKeywordResource);
            var     newKeyword   = await keywordService.CreateKeyword(keywordModel);

            var keyword = await keywordService.GetKeywordById(newKeyword.Id);

            var artistModel = _mapper.Map <Keyword, KeywordDTO>(keyword);

            return(Ok(new Response <KeywordDTO>(artistModel)));
        }
        protected override void InternalHasValidationResult(EntityValidationFacade validationFacade, KeyValuePair <string, List <dynamic> > property)
        {
            if (property.Value is null)
            {
                return;
            }

            validationFacade.RequestResource.Properties[Graph.Metadata.Constants.Resource.Keyword] = property.Value.Select(keyword =>
            {
                if (!Regex.IsMatch(keyword, Common.Constants.Regex.ResourceKey))
                {
                    if (!_keywordService.CheckIfKeywordExists(keyword, out string keywordId))
                    {
                        return(_keywordService.CreateKeyword(keyword));
                    }

                    return(keywordId);
                }

                return(keyword);
            }).ToList();
        }