public ActionResult Editing_Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <ProductionUnitViewModel> productionUnits)
        {
            ApplicationDbContext  db = new ApplicationDbContext();
            ProductionUnitService productionUnitService = new ProductionUnitService(db);

            if (productionUnits.Any())
            {
                foreach (var productionUnit in productionUnits)
                {
                    productionUnitService.Destroy(productionUnit);
                }
            }

            return(Json(productionUnits.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Editing_Destroy([DataSourceRequest] DataSourceRequest request, ProductionUnitViewModel currentProductionUnit)
        {
            ApplicationDbContext  db = new ApplicationDbContext();
            ProductionUnitService productionUnitService = new ProductionUnitService(db);

            if (currentProductionUnit != null)
            {
                if (currentProductionUnit.lastMeasureReceived != null)
                {
                    ModelState.AddModelError("inUse", new Exception("[[[Production Unit already in use]]]"));
                }
                else
                {
                    productionUnitService.Destroy(currentProductionUnit);
                }
            }

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