Where to place format functions

asp.net asp.net-mvc dapper n-tier-architecture

Question

I am building my first n-tier application.

  • The first tier is a ASP.net website.
  • The second is the business tier.
  • The third is the data tier with dapper.

The second and third layer are used in different websites.

When i have a numeric field for the tax option. 1 = High BTW and 2=Low btw and 3 = No btw Is it a good design to make an translate function in the business Artikel class? If the answer is no, where is the correct place to translate values. I use this function in the view to show the text instead of the number.

Example:

Public Function ArtBtwShow() As String
    Return ArtikelHelper.GetBtwName(ArtBtw)
End Function

GetBtwName Helper function:

Shared Function GetBtwName(Btw As String)
    Select Case Btw
        Case "0"
            Return "Geen"
        Case "1"
            Return "Laag"
        Case "2"
            Return "Hoog"

        Case Else
            Return ""
    End Select
End Function

Accepted Answer

I'm not sure exactly what you're trying to do, but it looks like you need to use an Enum rather than a string for your Btw object:

Public Enum Btw
    Green = 0
    Laag = 1
    Hoog = 2
End Enum

I think the business layer is the place to put this.

You then retrieve the decription like so:

Public Funtion GetName(btw As Btw)
    return [Enum].GetName(GetType(Btw), (int)btw)
End Function


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why