Beispiel #1
0
        public async Task <IActionResult> AddLanguage([FromBody] Language model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorResponse.Create(ModelState.GetErrorMessage())));
            }

            if (!model.Code.IsValidPartitionOrRowKey())
            {
                return(BadRequest(ErrorResponse.Create($"Invalid {nameof(model.Code)} value")));
            }

            if (!model.Name.IsValidPartitionOrRowKey())
            {
                return(BadRequest(ErrorResponse.Create($"Invalid {nameof(model.Name)} value")));
            }

            await _service.AddAsync(model.Code, model.Name);

            return(Ok());
        }