public ActionResult <TranslationItemDto> CreateTranslationItem([FromBody] TranslationItemDto dto, string language)
        {
            var duplicateTranslationItemExist = _context.TranslationItems
                                                .Any(x => x.Key == dto.Key);

            if (duplicateTranslationItemExist)
            {
                ModelState.AddModelError(nameof(TranslationItemDto.Key), $"{nameof(TranslationItemDto.Key)} is Duplicate.");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var translationItem = TranslationItemDto.Deconstruct(dto);

            translationItem.Language = language;


            _context.TranslationItems.Add(translationItem);
            _context.SaveChanges();

            dto = TranslationItemDto.Construct(translationItem);

            return(Created($"api/{language}/translationItems/{translationItem.Key}", dto));
        }
                public void UserIsReturned()
                {
                    var expectedDto = TranslationItemDto.Construct(_translationItem);

                    var result = (OkObjectResult)controller.GetTranslationItem(currentLanguage, _translationItem.Key).Result;

                    result.Value.Should().BeEquivalentTo(expectedDto);
                }
                public void TranslationItemIsReturned()
                {
                    var result = (CreatedResult)controller.CreateTranslationItem(dto, currentLanguage).Result;

                    var persistedTranslationItem = context.TranslationItems.FirstOrDefault();

                    var expectedDto = TranslationItemDto.Construct(persistedTranslationItem);

                    result.Value.Should().BeEquivalentTo(expectedDto);
                }
        public ActionResult <TranslationItemDto> GetTranslationItem(string language, string key)
        {
            var translationItem = _context.TranslationItems
                                  .FirstOrDefault(m => m.Key == key && m.Language == language);

            if (translationItem == null)
            {
                return(NotFound());
            }

            return(Ok(TranslationItemDto.Construct(translationItem)));
        }