public ActionResult Save(int?Id, int?CustomerId, decimal?Amount, string SerialNumber) { if (Amount != null) { CashCard cashCard = new CashCard(Id, Amount, SerialNumber); int result; result = cashCard.SaveData(); ViewBag.result = result; } return(View()); }
public ActionResult NewCard(CashCard cashCard) { int?result = 0; if (ModelState.IsValid) { //checking model state //check whether id is already exists in the database or not result = cashCard.SaveData(); if (result == 0) { ModelState.AddModelError("SerialNumber", "serial number is less or more than 12 digits"); ViewBag.result = result; return(View(cashCard)); } else if (result == 2) { ModelState.AddModelError("SerialNumber", "serial number is exist"); ViewBag.result = result; return(View(cashCard)); } else { //ModelState.Clear(); // ViewBag.result = result; return(RedirectToAction("NewCard", "NewCustomer", new { rresult = result })); } } else { ViewBag.result = result; return(View(cashCard)); } }