Skip to content

Instantly share code, notes, and snippets.

@guntidheerajkumar
Created November 6, 2015 06:29
Show Gist options
  • Save guntidheerajkumar/3fe3b3d27bcdd6944a83 to your computer and use it in GitHub Desktop.
Save guntidheerajkumar/3fe3b3d27bcdd6944a83 to your computer and use it in GitHub Desktop.
static ConcurrentDictionary<string, ToDoItem> todoItems = new ConcurrentDictionary<string, ToDoItem>();
// GET: /Sample/
public ActionResult Index()
{
var data = todoItems.Values;
return View(data.AsEnumerable<ToDoItem>());
}
public ActionResult AddItem()
{
return View();
}
[HttpPost]
public ActionResult AddItem(ToDoItem item)
{
item.Key = Guid.NewGuid().ToString();
var data = todoItems.TryAdd(item.Key, item);
return RedirectToAction("Index");
}
//Sample Class
public class ToDoItem
{
public string Key { get; set; }
public string Name { get; set; }
public bool IsComplete { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment