public JsonResult DeleteTown([DataSourceRequest] DataSourceRequest request, AdminTowns town)
        {
            var existingTown = this.Data.Towns.GetById(town.Id);

            this.Data.Towns.Delete(existingTown);
            this.Data.SaveChanges();

            return Json(new[] { town }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult EditTown([DataSourceRequest] DataSourceRequest request, AdminTowns town)
        {
            var existingTown = this.Data.Towns.GetById(town.Id);

            if (town != null && ModelState.IsValid)
            {
                existingTown.Name = town.Name;
                existingTown.AreaId = town.AreaId;

                this.Data.SaveChanges();
            }

            return Json((new[] { town }.ToDataSourceResult(request, ModelState)), JsonRequestBehavior.AllowGet);
        }
        public JsonResult CreateTown([DataSourceRequest] DataSourceRequest request, AdminTowns town)
        {
            if (town != null && ModelState.IsValid)
            {
                var category = this.Data.Areas.GetById(town.AreaId);

                var newTown = new Town
                {
                    Name = town.Name,
                    AreaId = town.AreaId,

                };

                this.Data.Towns.Add(newTown);
                this.Data.SaveChanges();

                town.Id = newTown.Id;
            }

            return Json(new[] { town }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }