public async Task <IActionResult> OnCreatePost(PartsCreateViewModel vm) { if (!ModelState.IsValid) { return(BadRequest("The image specified does not follow guidelines. Please ensure the file has a valid extension and size.")); } var createSuccessful = await _partsService.TryCreatePart(vm.MfrsPartNumber, vm.PartCategoryId, vm.CataloguePartNumber, vm.Name, vm.Description, vm.PriceIn, vm.PriceOut, vm.Vendor, vm.MinimumStock, vm.Image); if (createSuccessful) { return(CreatedAtAction("Parts", vm.MfrsPartNumber)); } else { return(BadRequest("Unable to add the specified part. Please try again and contact site administration if the problem persists.")); } }