Exemplo n.º 1
0
        public ActionResult Editing_Create([DataSourceRequest] DataSourceRequest request, ProductionUnitViewModel currentProductionUnit)
        {
            ApplicationDbContext  db = new ApplicationDbContext();
            ProductionUnitService productionUnitService = new ProductionUnitService(db);

            var results = new List <ProductionUnitViewModel>();

            if (ModelState.IsValid)
            {
                productionUnitService.Create(currentProductionUnit);
            }

            return(Json(new[] { currentProductionUnit }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Editing_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <ProductionUnitViewModel> productionUnits)
        {
            ApplicationDbContext  db = new ApplicationDbContext();
            ProductionUnitService productionUnitService = new ProductionUnitService(db);

            var results = new List <ProductionUnitViewModel>();

            if (productionUnits != null && ModelState.IsValid)
            {
                foreach (var productionUnit in productionUnits)
                {
                    productionUnitService.Create(productionUnit);
                    results.Add(productionUnit);
                }
            }

            return(Json(results.ToDataSourceResult(request, ModelState)));
        }