public ActionResult Create([Bind("ixMaterial,sMaterial,sDescription,ixMaterialType,ixBaseUnit,bTrackSerialNumber,bTrackBatchNumber,bTrackExpiry,nDensity,ixDensityUnit,nShelflife,ixShelflifeUnit,nLength,ixLengthUnit,nWidth,ixWidthUnit,nHeight,ixHeightUnit,nWeight,ixWeightUnit")] MaterialsPost materials) { if (ModelState.IsValid) { materials.UserName = User.Identity.Name; //Custom Code Start | Replaced Code Block //Replaced Code Block Start //_materialsService.Create(materials); //return RedirectToAction("Index"); //Replaced Code Block End var ixMaterial = _materialsService.Create(materials).Result; return(RedirectToAction("Edit", "Materials", new { id = ixMaterial })); //Custom Code End } //Custom Code Start | Replaced Code Block //Replaced Code Block Start //ViewBag.ixBaseUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //ViewBag.ixDensityUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //ViewBag.ixHeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //ViewBag.ixLengthUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //ViewBag.ixMaterialType = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType"); //ViewBag.ixShelflifeUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //ViewBag.ixWeightUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //ViewBag.ixWidthUnit = new SelectList(_materialsService.selectUnitsOfMeasurement().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //Replaced Code Block End ViewBag.ixBaseUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementQuantity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); ViewBag.ixDensityUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementDensity().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); ViewBag.ixHeightUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); ViewBag.ixLengthUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); ViewBag.ixMaterialType = new SelectList(_materialsService.selectMaterialTypes().Select(x => new { x.ixMaterialType, x.sMaterialType }), "ixMaterialType", "sMaterialType"); ViewBag.ixShelflifeUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementTime().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); ViewBag.ixWeightUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementWeight().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); ViewBag.ixWidthUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement"); //Custom Code End return(View(materials)); }