Beispiel #1
0
        public IActionResult Post([FromBody] myData value)
        {
            var validationResult = value.Validate();

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }
            _memCache.Add(value);
            Log.Information("Adding information about serials");
            Log.Warning("Some warning");
            Log.Error("Here comes an error");
            Log.Information($"This information about serials have been added: {value}");
            return(Ok($"{value.ToString()} has been added"));
        }
Beispiel #2
0
        public IActionResult Put(Guid id, [FromBody] myData value)
        {
            if (!_memCache.Has(id))
            {
                return(NotFound("No such"));
            }

            var validationResult = value.Validate();

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }

            var previousValue = _memCache[id];

            _memCache[id] = value;

            return(Ok($"{previousValue.ToString()} has been updated to {value.ToString()}"));
        }