using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LAB_Knockout.Models;

namespace LAB_Knockout.Controllers
{
    public class DataController : Controller
    {
        LabKnockoutContext db = new LabKnockoutContext();
       
        public ActionResult AddPerson(Person person)
        {
            db.Persons.Add(person);
            db.SaveChanges();

            return Json("Operation completed", JsonRequestBehavior.AllowGet);
        }

        public ActionResult GetPersons()
        {
            var persons = db.Persons.ToList();

            return Json(persons, JsonRequestBehavior.AllowGet);
        }
    }
}
