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

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

            _memCache.Add(value);

            Log.Information($"New model added {value.ToString()}");

            return(Ok($"{value.ToString()} has been added"));
        }
Exemple #2
0
            public IActionResult Put(Guid id, [FromBody] Lab1Data 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()}"));
            }
Exemple #3
0
        public IActionResult Post([FromBody] Lab1Data value)
        {
            var validationResult = value.Validate();

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

            _memCache.Add(value);

            return(Ok($"{value.ToString()} - запись успешно добавлена!"));
        }