Exemplo n.º 1
0
 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) }
         });
     }
 }
Exemplo n.º 2
0
        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");
        }