public ActionResult Save(int?id, string username, int?CardId, string telephone, int?countryId, int?cityId, int?townid, string street, string password, string name) { if (username != null) { Customer customer = new Customer(id, username, CardId, telephone, countryId, cityId, townid, street, password, name); int result; result = customer.SaveData(); ViewBag.result = result; } return(View()); }
public ActionResult Newcustomer(Customer customer) { int?result = 0; if (ModelState.IsValid) { //checking model state //check whether id is already exists in the database or not result = customer.SaveData(); if (result == 0) { ModelState.AddModelError("Telephone", " telephone number must contains 10 numbers"); ViewBag.result = result; return(View(customer)); } else if (result == 2) { ModelState.AddModelError("Username", "Username is exist"); ViewBag.result = result; return(View(customer)); } else if (result == 3) { ModelState.AddModelError("Telephone", "the telphone number must start with either 056 or 059 "); ViewBag.result = result; return(View(customer)); } else { return(RedirectToAction("Newcustomer", "NewCustomer", new { rresult = result })); //ViewBag.result = result; //return View(customer); } } else { ViewBag.result = result; return(View(customer)); } }