<commit_before>﻿@using WebMatrix.Data;
@using WebMatrix.WebData;
@functions {

    /* General: some functions created with code from old 'provider-dashboard-profile.cshtml' file
    */

    /* Get a data row with the User information identified with 'userId' from the database
    */
    public static dynamic GetUserRow(int userId) {

        // Commented unused vars:
        //var stringPosted = "Nothing";
        //var theDate = DateTime.Now.ToString("yyyy-MM-dd");
        
        // Implemented a basic, per-page, cache, faster and simplified for each page
        var u = PageData["userow:" + userId.ToString()];
        if (u == null){
            using (var db = Database.Open("sqlloco")){
                var sqluser = 
                    //"exec GetUserDetails @0";
                    // NOTE: UserID is needed!
                    // NOTE2: remove location details from this table and query, use GetUserWithContactData
                    @"
                        SELECT
                            a.UserID,
                            FirstName, 
                            LastName,
                            SecondLastName,
                            MiddleIn,
                            (dbo.fx_concat(dbo.fx_concat(dbo.fx_concat(A.FirstName, dbo.fx_concatBothOrNothing(A.MiddleIn, '.', ''), ' '), A.LastName, ' '), A.SecondLastName, ' ')) As FullName,
                            Photo,
                            PreferredLanguageID,
                            PreferredCountryID,
                            IsCustomer,
                            IsProvider,
                            (CASE WHEN IsProvider=1 AND (
                                SELECT count(*) FROM UserProfilePositions As UPS WHERE UPS.UserID = A.UserID AND UPS.Active=1
                                ) > 0 THEN Cast(1 As bit)
                                ELSE Cast(0 As bit)
                            END) As IsActiveProvider,
                            MobilePhone,
                            AlternatePhone,
                            AddressLine1,   
                            AddressLine2,
                            A.City,
                            A.StateProvinceID,
                            A.CountryID,
                            PC.PostalCode,
                            A.PostalCodeID,
                            a.CreatedDate As MemberSinceDate,
                            PublicBio,
                            BirthYear,
                            GenderID
                            ,UP.Email
                            ,IAuthZumigoVerification
                            ,IAuthZumigoLocation
                            --,ADD_Details 
                        from users A
                             INNER JOIN
                            UserProfile As UP
                              ON UP.UserID = A.UserID
                             LEFT JOIN
                            PostalCode As PC
                              ON PC.PostalCodeID = A.PostalCodeID
                            -- left join dbo.userprofilepositionadditional b 
                            --  ON a.userid = b.userid
                        where a.UserID = @0
                    ";
                u = db.QuerySingle(sqluser, userId);
            }
            PageData["userow:" + userId.ToString()] = u;
        }
        return u;
    }
    public static dynamic GetUserRowWithContactData(int userId) {
        // Implemented a basic, per-page, cache, faster and simplified for each page
        var u = PageData["userow:" + userId.ToString()];
        if (u == null){
            using (var db = Database.Open("sqlloco")){
                var sqluser = 
                    //"exec GetUserDetails @0";
                    // NOTE: UserID is needed!
                    @"
                        SELECT
                            U.UserID
                            ,U.FirstName
                            ,U.LastName
                            ,U.MiddleIn
                            ,U.CreatedDate As MemberSinceDate
                            ,U.PublicBio
                            ,U.MobilePhone
                            ,P.Email
                            ,U.BirthYear
                            ,U.GenderID

                            ,Photo
                            ,PreferredLanguageID
                            ,PreferredCountryID
                            ,IsCustomer
                            ,IsProvider
                            (CASE WHEN IsProvider=1 AND (
                                SELECT count(*) FROM UserProfilePositions As UPS WHERE UPS.UserID = A.UserID AND UPS.Active=1
                                ) > 0 THEN Cast(1 As bit)
                                ELSE Cast(0 As bit)
                            END) As IsActiveProvider,
                            ,MobilePhone
                            ,AlternatePhone

                            ,L.AddressLine1
                            ,L.AddressLine2
                            ,L.City
                            ,SP.StateProvinceName
                            ,SP.StateProvinceCode
                            ,PC.PostalCode

                        FROM
                            Users As U
                             INNER JOIN
                            UserProfile As P
                              ON P.UserID = U.UserID
                             LEFT JOIN
                            ServiceAddress As L
                              ON L.UserID = U.UserID
                                AND L.PreferredAddress = 1
                             LEFT JOIN<commit_msg>Fixed a bug in the modified SQL to get user row with contact data.<commit_after>﻿@using WebMatrix.Data;
@using WebMatrix.WebData;
@functions {

    /* General: some functions created with code from old 'provider-dashboard-profile.cshtml' file
    */

    /* Get a data row with the User information identified with 'userId' from the database
    */
    public static dynamic GetUserRow(int userId) {

        // Commented unused vars:
        //var stringPosted = "Nothing";
        //var theDate = DateTime.Now.ToString("yyyy-MM-dd");
        
        // Implemented a basic, per-page, cache, faster and simplified for each page
        var u = PageData["userow:" + userId.ToString()];
        if (u == null){
            using (var db = Database.Open("sqlloco")){
                var sqluser = 
                    //"exec GetUserDetails @0";
                    // NOTE: UserID is needed!
                    // NOTE2: remove location details from this table and query, use GetUserWithContactData
                    @"
                        SELECT
                            a.UserID,
                            FirstName, 
                            LastName,
                            SecondLastName,
                            MiddleIn,
                            (dbo.fx_concat(dbo.fx_concat(dbo.fx_concat(A.FirstName, dbo.fx_concatBothOrNothing(A.MiddleIn, '.', ''), ' '), A.LastName, ' '), A.SecondLastName, ' ')) As FullName,
                            Photo,
                            PreferredLanguageID,
                            PreferredCountryID,
                            IsCustomer,
                            IsProvider,
                            (CASE WHEN IsProvider=1 AND (
                                SELECT count(*) FROM UserProfilePositions As UPS WHERE UPS.UserID = A.UserID AND UPS.Active=1
                                ) > 0 THEN Cast(1 As bit)
                                ELSE Cast(0 As bit)
                            END) As IsActiveProvider,
                            MobilePhone,
                            AlternatePhone,
                            AddressLine1,   
                            AddressLine2,
                            A.City,
                            A.StateProvinceID,
                            A.CountryID,
                            PC.PostalCode,
                            A.PostalCodeID,
                            a.CreatedDate As MemberSinceDate,
                            PublicBio,
                            BirthYear,
                            GenderID
                            ,UP.Email
                            ,IAuthZumigoVerification
                            ,IAuthZumigoLocation
                            --,ADD_Details 
                        from users A
                             INNER JOIN
                            UserProfile As UP
                              ON UP.UserID = A.UserID
                             LEFT JOIN
                            PostalCode As PC
                              ON PC.PostalCodeID = A.PostalCodeID
                            -- left join dbo.userprofilepositionadditional b 
                            --  ON a.userid = b.userid
                        where a.UserID = @0
                    ";
                u = db.QuerySingle(sqluser, userId);
            }
            PageData["userow:" + userId.ToString()] = u;
        }
        return u;
    }
    public static dynamic GetUserRowWithContactData(int userId) {
        // Implemented a basic, per-page, cache, faster and simplified for each page
        var u = PageData["userow:" + userId.ToString()];
        if (u == null){
            using (var db = Database.Open("sqlloco")){
                var sqluser = 
                    //"exec GetUserDetails @0";
                    // NOTE: UserID is needed!
                    @"
                        SELECT
                            U.UserID
                            ,U.FirstName
                            ,U.LastName
                            ,U.MiddleIn
                            ,U.CreatedDate As MemberSinceDate
                            ,U.PublicBio
                            ,U.MobilePhone
                            ,P.Email
                            ,U.BirthYear
                            ,U.GenderID

                            ,Photo
                            ,PreferredLanguageID
                            ,PreferredCountryID
                            ,IsCustomer
                            ,IsProvider
                            ,(CASE WHEN IsProvider=1 AND (
                                SELECT count(*) FROM UserProfilePositions As UPS WHERE UPS.UserID = U.UserID AND UPS.Active=1
                                ) > 0 THEN Cast(1 As bit)
                                ELSE Cast(0 As bit)
                            END) As IsActiveProvider
                            ,MobilePhone
                            ,AlternatePhone

                            ,L.AddressLine1
                            ,L.AddressLine2
                            ,L.City
                            ,SP.StateProvinceName
                            ,SP.StateProvinceCode
                            ,PC.PostalCode

                        FROM
                            Users As U
                             INNER JOIN
                            UserProfile As P
                              ON P.UserID = U.UserID
                             LEFT JOIN
                            ServiceAddress As L
                              ON L.UserID = U.UserID
                                AND L.PreferredAddress = 1
                             LEFT JOIN
{'fraction_non_alphanumeric': 0.061090973388736626, 'fraction_numerical': 0.0033595614888161968, 'mean_word_length': 0.7650179435169293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5505536', 'n_tokens_mistral': 2538, 'n_tokens_neox': 2408, 'n_words': 610}