public IActionResult Post([FromBody] PhonesData value) { var validationResult = value.Validate(); if (!validationResult.IsValid) { return(BadRequest(validationResult.Errors)); } _memCache.Add(value); return(Ok($"{value.ToString()} был добавлен!")); }
public IActionResult Put(Guid id, [FromBody] PhonesData 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()} обновлён до {value.ToString()}")); }