public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, BusinessSectorViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                BusinessSector toDelete = this.Data.BusinessSectors.Find(model.Id);
                toDelete.IsDeleted = true;
                this.Data.BusinessSectors.Update(toDelete);

                // this.data.Towns.Delete(model.Id);
            }

            return(this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)));
        }
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, BusinessSectorViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                BusinessSector sector = this.Data.BusinessSectors.All().Where(s => s.Name == model.Name).FirstOrDefault();
                if (sector == null)
                {
                    BusinessSector toUpdate = this.Data.BusinessSectors.Find(model.Id);
                    toUpdate.Name = model.Name;
                    this.Data.BusinessSectors.Update(toUpdate);
                }
            }

            return(this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)));
        }
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, BusinessSectorViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                BusinessSector town = this.Data.BusinessSectors.All().Where(s => s.Name == model.Name).FirstOrDefault();
                if (town == null)
                {
                    BusinessSector toAdd = new BusinessSector {
                        Name = model.Name
                    };
                    this.Data.BusinessSectors.Add(toAdd);
                    model.Id = toAdd.Id;
                }
            }

            return(this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)));
        }