In Focus

Forums - C# Corner

Forum guidelines
Mark Tabor

Mark Tabor

  • 1.2k
  • 394
  • 43.1k

how to check already existing record in mvc

Jan 14 2018 5:28 AM
I am new to mvc and i am creating application with built in read/write controller and views using entity framework , below is my create customer controller now i want to check the unique mobile number i mean mobile number for each customer should be unique , how to check that below is my controller code.
public ActionResult Create([Bind(Include = "Cutomer_ID,Customer_Name,Phone,Location,Email,gender")] Customer customer, string BtnPrevious, string BtnNext)
// bool isexists = db.customers.Any(x => x.ContactId == _customer.ContactId)
if (ModelState.IsValid)
//bool contactExists = db.Customers.Any(contact => contact.Customer_Name.Equals());
// return View("~/Views/Orders/Details.cshtml");
// return RedirectToAction("~/Views/Shirts/Index.cshtml");
return View(customer);

Answers (1)


Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now