using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Globalization;
using jQWidgetsMVCDemo.Models;

namespace jQWidgetsMVCDemo.Controllers
{
	public class EmployeeController : Controller
	{
		private EmployeesDBEntities db = new EmployeesDBEntities();

		public JsonResult GetEmployees()
		{
			var dbResult = db.Employees.ToList();
			var employees = (from employee in dbResult
				select new
				{
					employee.FirstName,
					employee.LastName,
					employee.EmployeeID,
					employee.BirthDate,
					employee.HireDate,
					employee.ManagerID,
					employee.Title,
					employee.City,
					employee.Country,
					employee.Address
				});
			return Json(employees, JsonRequestBehavior.AllowGet);
		}

		// GET: /Employee/
		public ActionResult Index()
		{
			return View(db.Employees.ToList());
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				db.Dispose();
			}
			base.Dispose(disposing);
		}
	}
}
