ASP.NET MVC - How do I implement validation when using Data Repositories? (Visual Basic)

Posted by rockinthesixstring on Stack Overflow See other posts from Stack Overflow or by rockinthesixstring
Published on 2010-06-15T03:24:55Z Indexed on 2010/06/15 3:32 UTC
Read the original article Hit count: 227

I've built a UserRepository interface to communicate with my LINQ to SQL Data layer, but I'm trying to figure out how to implement validation.

Here is what my AddUser subroutine looks like

Public Sub AddUser(ByVal about As String, ByVal birthdate As DateTime, ByVal openid As String, ByVal regionid As Integer, ByVal website As String) Implements IUserRepository.AddUser
    Dim user = New User
    user.About = about
    user.BirthDate = birthdate
    user.LastSeen = DateTime.Now
    user.MemberSince = DateTime.Now
    user.OpenID = openid
    user.RegionID = regionid
    user.UserName = String.Empty
    user.WebSite = website

    dc.Users.InsertOnSubmit(user)
    dc.SubmitChanges()
End Sub

And then my controller will simply call AddUser(...)

But I haven't the foggiest idea on how to implement both client side and server side validation on this.
(I think I would prefer to use jQuery AJAX and do all of the validation on the server, but I'm totally open to opinions)

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about vb.net