public JsonResult AddLocation() { try { Location loc = new Location(); loc.Department = Request.Form["Department"]; loc.RoomNumber = Request.Form["RoomNumber"]; loc.IsActive = true; LocationRepository locationRepo = new LocationRepository(); locationRepo.Add(loc); return Json(new { error = false, Id = loc.Id, Name = loc.Department }); } catch { return Json(new { error = true }); } }