Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (38 sloc) 1.24 KB
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace DumApi.Controllers
public class MyValue
public string Id { get; set; }
public int Value { get; set; }
public class ValuesController : ControllerBase
private static readonly Dictionary<string, MyValue> _values = new Dictionary<string, MyValue>();
public ActionResult<IEnumerable<MyValue>> Get() => _values.Values;
public ActionResult<MyValue> Get(string id) => _values[id];
public IActionResult Post(MyValue value)
if (_values.ContainsKey(value.Id))
return BadRequest("Object already exists.");
_values[value.Id] = value;
return Ok();
public void Put(MyValue value) => _values[value.Id] = value;
public void Delete(string id) => _values.Remove(id);
public void Clear() => _values.Clear();
You can’t perform that action at this time.