0

Alright so I have a user table that I would like to check against. This user table has a username, email, and accountnumber. Would I would like to do is check if anyone of those has been taken and if it has return if it has been taken.

I was thinking about doing an array example

CHECK AGAINST TABLE 
IF USERNAME MATCHES INSERT @ARRAY "TRUE"
IF EMAIL MATCHES INSERT @ARRAY "TRUE"
ETC.

Then on the C# side I will call the array and check by index

If registrationValidationArray[0] = "true"
{
   ViewBag.UserNameTaken = "True"
   return view("Registration")
   // On cshtml post error next to username that it has been taken
}

So my question is does this approach sound logical and sound like it will work or is there another approach that might help me here procedure wise. Another developer suggested an incremental for the procedure so if username is taken +1 and then on the C# side display according to the numeric value but I couldn't wrap my head around that one. Anyone know of a better way or see a flaw in my logic?

NitroFrost
  • 133
  • 4
  • 20
  • Sounds like a good way for somebody on your front end to find out what usernames/account numbers are in use on your system.. – Paddy Nov 14 '13 at 16:59
  • Well at the moment I just need to worry about getting this working. Later I can worry about something like that. @Paddy how is this different though from any other registration such as when you register a new email with google? I can see where your coming from but at the same time this needs to be a check and I can't just tell the user hey one or more of what you entered is already in use. What would be a constructive way to go about it then is what I am asking. – NitroFrost Nov 14 '13 at 17:09
  • Rather than informing them of exactly what is in use, just state that the details entered are already in use, and ask for a different set of details. Better yet would be for you to generate usernames for them, removing the need to check. – Paddy Nov 15 '13 at 09:12

1 Answers1

1

If you are using the Telerik OpenAccess ORM and you have a stored procedure returning the details from the check I would suggest you to map this stored procedure to a Domain Method, then OpenAccess will return you an object with nicely named properties. You can use the returned object instead of the array. This will make you code more readable and easier to maintain. Now you should remember what means index 0 and index 1, even if you define the indexes as constants it will not be an eye-catching code.