views:

14

answers:

1

I've got a Controller ActionResult that looks like this

Function Edit(ByVal user As Domain.User, ByVal id As Integer) As ActionResult
    Dim _user As Domain.User = user
    If ModelState.IsValid Then

        If Not String.IsNullOrEmpty(user.UserName) AndAlso _
            Not String.IsNullOrEmpty(user.WebSite) AndAlso _
            Not String.IsNullOrEmpty(user.Email) AndAlso _
            Not String.IsNullOrEmpty(user.About) AndAlso _
            Not user.Region Is Nothing AndAlso _
            Not user.BirthDate Is Nothing AndAlso _
            Not user.isProfileComplete = True Then

            _user.isProfileComplete = True
            _user.Reputation = user.Reputation + 10

            UserService.UpdateUser(_user)

        Else
            UserService.UpdateUser(_user)
        End If

        UserService.SubmitChanges()
        Session("UserInfo") = Nothing

        Return RedirectToAction("Details", "Users", New With {.id = id, .slug = user.UserName})
    Else
        Return View(user)
    End If
End Function

After it goes to the Service for validation, it gets passed to the Repository which looks like this

    Public Sub UpdateUser(ByVal user As User) Implements IUserRepository.UpdateUser
        Dim _user = (From u In dc.Users
            Where u.ID = user.ID
            Select u).Single

        With _user
            .About = user.About
            .BirthDate = user.BirthDate
            .Email = user.Email
            .isClosed = user.isClosed
            .isProfileComplete = user.isProfileComplete
            .RegionID = user.RegionID
            .Reputation = user.Reputation
            .UserName = user.UserName
            .WebSite = user.WebSite
        End With

    End Sub

The problem I'm having is with THREE fields.

isProfileComplete, isClosed & Reputation are all getting "Updated" as "NULL".

I even tried creating hidden fields in the View to contain the data, but nothing I'm doing seems to properly pass those three fields. All other fields update without issue.

Can anyone tell me what I'm missing?

A: 

forget this one... I figured it out.

I missed putting the following fields into the form (I had them at the bottom, out of the form)

<%: Html.HiddenFor(Function(model) model.isProfileComplete)%>
<%: Html.HiddenFor(Function(model) model.isClosed)%>
<%: Html.HiddenFor(Function(model) model.Reputation)%>
rockinthesixstring