Ejemplo n.º 1
0
        public ActionResult Locations_Create([DataSourceRequest]DataSourceRequest request, LocationGridInputModel location)
        {
            var newId = 0;
            if (this.ModelState.IsValid)
            {
                var entity = new Location()
                {
                    Name = location.Name
                };

                this.locations.Create(entity);
                newId = entity.Id;
            }

            var locationToDisplay = this.locations
                .GetAll()
                .To<LocationGridViewModel>()
                .FirstOrDefault(x => x.Id == newId);

            return this.Json(new[] { locationToDisplay }.ToDataSourceResult(request, this.ModelState));
        }
Ejemplo n.º 2
0
        public ActionResult Locations_Update([DataSourceRequest]DataSourceRequest request, LocationGridInputModel location)
        {
            if (this.ModelState.IsValid)
            {
                var entity = this.locations.GetAll().FirstOrDefault(x => x.Id == location.Id);
                entity.Name = location.Name;
                this.locations.Update(entity);
            }

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