public IActionResult Create(VehiclesModel vehicles, IFormCollection formCollection) { IActionResult returnpath = View(vehicles); VehicleMakemodelMapping mapping = new VehicleMakemodelMapping(); //var _modelContext = new VehiclesContext(); try { Validation(vehicles); decimal VmakeId = Convert.ToDecimal(HttpContext.Request.Form["VmakeId"]); decimal VmodelId = Convert.ToDecimal(HttpContext.Request.Form["VmodelId"]); mapping = _vehicleService.GetMakeModelIDList(mapping, VmakeId, VmodelId); if (ModelState.IsValid) { if (mapping != null) { var record = new VehicleRecords() { VmmpId = mapping.VmmpId }; _modelContext.VehicleRecords.Add(record); _modelContext.SaveChanges(); decimal id = record.VrId; if (id != 0) { _vehicleService.InsertIntoVehicleRecordProperties(vehicles, id); } } returnpath = RedirectToAction("Index"); } else { ViewBag.ListOfVehicles = _vehicleService.LoadVehicleTypeList(); returnpath = View(vehicles); } } catch (Exception ex) { _logger.LogError(" Exception on creating new record: " + ex); } return(returnpath); }