Denmark Puso

Denmark Puso

  • NA
  • 232
  • 48k

how to check in my dabase if the value is existing?

Aug 25 2019 9:16 PM
im using asp.net mvc 5 im new bee here. my problem is i have a tbl_register the content is 
 
Username
password
repeat-password
contact number
 
then i fill up the form, all i need is to validate if the contact number is existing to another table in tbl_client. this is my code. my code is not working
 
  1. var agent = _clientService.Find(x => x.ContactPrimary == newUser.ContactNumber);  
  2.   
  3.                   if (agent != null)  
  4.                   {  
  5.                       var client = new Client  
  6.                       {  
  7.                           ParentClientId = agent.FirstOrDefault().Id,  
  8.                           FirstName = "",  
  9.                           LastName = "",  
  10.                           MiddleName = "",  
  11.                           Suffix = "",  
  12.                           ContactPrimary = "",  
  13.                           ContactSecondary = "",  
  14.                           Age = 0,  
  15.                           Gender = "",  
  16.                           CountryId = 0,  
  17.                           StateId = 0,  
  18.                           CityId = 0,  
  19.                           TownId = 0,  
  20.                           EmailAddress = "",  
  21.                           Postcode = 0,  
  22.                           Commission = 0,  
  23.                           SubAgentCommissionPercentage = 0,  
  24.                           Address = ""  
  25.                       };  
  26.                       _clientService.Add(client);  
  27.                   }  
 

Answers (3)