public IActionResult Create([Bind("baseId,retailPrice,wholeSalePrice,productKDV,barcodeID, name,sellersID,detailsId")] baseproduct baseproduct) { string error_msg = ""; if (ModelState.IsValid) { if (baseproduct.barcodeID.Length == 13) { barcodeController barcode = new barcodeController(_context); string checkDigit = barcode.calcCheckDigit(baseproduct.barcodeID.Substring(0, 12)); if (checkDigit != baseproduct.barcodeID.Substring(12, 1)) { error_msg = "Barkod kontrol karakteri hatalı."; } } else { error_msg = "Barkod Uzunluğu 13 karakter olmalı"; } if (error_msg != "") { ModelState.AddModelError("barkod", error_msg); } else { _context.Add(baseproduct); _context.SaveChanges(); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } } return(View(baseproduct)); }