public async Task <HttpResponseMessage> CreateDictionary(DictionaryDTO dictionaryDto)
        {
            if (dictionaryDto == null)
            {
                _logger.Info(
                    $"DictionaryController.CreateDictionary [ClientAddress: {GetClientAddress()}]");

                throw new ApplicationException("Object DictionaryDTO is null.");
            }

            _logger.Info(
                $"DictionaryController.CreateDictionary [ClientAddress: {GetClientAddress()}, " +
                $"DictionaryName: {dictionaryDto.Name}, " +
                $"Version: {dictionaryDto.Version}, " +
                $"Id: {dictionaryDto.Id}]");

            try
            {
                var res = await _service.CreateNewDictionaryAsync(dictionaryDto);

                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception ex)
            {
                _logger.Error(GetErrorMessage(ex));

                return(Request.CreateResponse(HttpStatusCode.InternalServerError, GetErrorMessage(ex)));
            }
        }
Beispiel #2
0
        public void AddDictionaryTest()
        {
            string name    = "currency";
            string version = "1.0.0";
            //string id = "1";
            DictionaryDTO dict = new DictionaryDTO
            {
                Name     = name,
                Metadata = new JObject(),
                Version  = version
            };

            service.CreateNewDictionaryAsync(dict);
            var    a    = service.GetDictionaryAsync(name, version, true);
            string json = JsonConvert.SerializeObject(a, Formatting.Indented, new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });
        }