public ActionResult CreateAjaxEditing(Region region)
 {
     if (ModelState.IsValid)
     {
         _repository.Insert(region);
         _repository.SaveChanges();
     }
     var regions = new List<Region>(_repository.ListIncluding<Region>(r => r.Locations));
     return PartialView("_SelectAjaxEditing", new GridModel(regions));
 }
        public ActionResult Create(Region region)
        {
            if (ModelState.IsValid)
            {
                _repository.Insert(region);
                _repository.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(region);
        }
        public ActionResult EditAjaxEditing(Region region)
        {
            // Get and update the existing record
            //          (only needed if using NHib repo - else the line
            //          _repository.Update(region);
            //          tries to set RegionId to null (since the field is mapped to readonly) , and
            //          throws error: "could not delete collection: [Trails2012.Domain.Region.Locations#2")
            Region savedRegion = _repository.GetById<Region>(region.Id);

            if (ModelState.IsValid)
            {
                UpdateModel(savedRegion);
                _repository.Update(savedRegion);
                _repository.SaveChanges();
            }
            var regions = new List<Region>(_repository.ListIncluding<Region>(r => r.Locations));
            return PartialView("_SelectAjaxEditing", new GridModel(regions));
        }