public IActionResult GetRegistrationStatistics() { using (var context = new RegistrationContext()) { return new ObjectResult(new[] { new { name= "ASP.NET 5", count=context.Registrations.Count(x=>x.Session1) }, new { name= "DevOps", count=context.Registrations.Count(x=>x.Session2) } }); } }
public IActionResult Register(Registration model) { if (!ModelState.IsValid) { return View("Index", model); } using (var context = new RegistrationContext()) { context.Registrations.Add(model); context.SaveChanges(); } ViewBag.Message = "Your registration was succesful. You will be contacted soon."; ModelState.Clear(); return View("Index"); }