Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top