예제 #1
0
        public IActionResult Put(Guid id, [FromBody] MyModData value)
        {
            Log.Information("Acquiring product info");
            Log.Warning("Someone is try to change information");

            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;

            Log.Information($"Date change {DateTime.Now}");
            Log.Debug($"Attempt to change information");

            return(Ok($"{previousValue.ToString()} has been updated to {value.ToString()}"));
        }
예제 #2
0
        public IActionResult Post([FromBody] MyModData value)
        {
            var validationResult = value.Validate();

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

            _memCache.Add(value);

            return(Ok($"{value.ToString()} has been added"));
        }
예제 #3
0
        public IActionResult Post([FromBody] MyModData value)
        {
            Log.Information("Acquiring product info");
            Log.Error("The entered data is not correct");

            var validationResult = value.Validate();

            if (!validationResult.IsValid)
            {
                Log.Information($"Date added {DateTime.Now}");
                Log.Debug($"Uncorrected data");
                return(BadRequest(validationResult.Errors));
            }
            _memCache.Add(value);

            return(Ok($"{value.ToString()} has been added"));
        }
예제 #4
0
        public IActionResult Put(Guid id, [FromBody] MyModData 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()}"));
        }