<commit_before>﻿@using WebMatrix.Data;
@{
    Layout = LcUrl.RenderLangPath + "_SiteLayout.cshtml";
    bool performSearch = false;
    // WelcomePopup is required again #514
    PageData["ShowWelcomePopup"] = true;
    
    PageData["Customer"] = LcData.UserInfo.GetUserRow();
    
    /* Getting search parameters */
    var serviceType = PageData["s"] = Request["s"];
    var serviceCat = PageData["c"] = Request["c"];
    var serviceLocation = PageData["location"] = Request["location"];
    var serviceDate = PageData["date"] = Request["date"];
    
    if (!String.IsNullOrWhiteSpace(serviceType) ||
        !String.IsNullOrWhiteSpace(serviceCat)) {
        performSearch = true;
    }
    bool categorizedResults = (String.IsNullOrEmpty(serviceCat) ? false : true);
    dynamic posrow = null;

    if (performSearch) {
        PageData["BodyClass"] = "search";
        PageData["IsHomePage"] = true; // consider true for now just all home script are shared
        Page.Title = "Search Results...";
        LcAssets.AddStyle(LcUrl.AppPath + "Styles/Search.css");
        
        // Building sql parameters:
        var LC_Term  = "%" + serviceType + "%";
        var LC_Cat = serviceCat;
        // Performing search:
        using (var db = Database.Open("sqlloco")) {
            if (categorizedResults) {
                // By category:
                var searchsql = "EXEC SearchPositionsByCategory @0, @1, @2, @3"; // "EXEC dbo.GetSearchResults @0,@1,@2,@3";
                posrow = db.Query(searchsql, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID(), LC_Cat, serviceLocation);
            } else {
                // By PositionSingular
                var searchsql = "EXEC dbo.SearchProvidersByPositionSingular @0,@1,@2";
                posrow = db.Query(searchsql, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID(), LC_Term);
            }
        }
    } else {
        PageData["BodyClass"] = "home";
        PageData["IsHomePage"] = true;
        Page.Title = "Make your life better.";
    }
}
@helper searchForm(){
        // We will return an array for the search-location autocomplete script
        string locationsCSV = "'San Francisco, CA', 'Other locations coming soon'";
        if (LcData.GetCurrentCountryID() == 2){
            locationsCSV = "'Barcelona', 'Other locations coming soon'";
        }
        PageData["InlineScript"] = @"
            window['LC'] = window['LC'] || {};
            LC.searchLocations = [ " + locationsCSV + @" ];
        ";
        <form id="homeSearch" method="get" class="lightform">
			<fieldset class="search-options">
                <ul>
                    <li class="search-service">
                        <label for="search-service">Search for a (e.g. Tutor, Gardener...)</label>
                        <input id="search-service" type="text" name="s" placeholder="Massage Therapist" value="@Request["s"]" />
                    </li>
                    <li class="search-location">
                        <label for="search-location">Where</label>
                        <input id="search-location" type="text" name="location" placeholder="San Francisco, CA" value="@Request["location"]" />
                    </li>
                    <li class="search-date">
                        <label for="search-date">When</label>
                        <input id="search-date" class="date-pick" type="text" name="date" value="@(DateTime.Today.ToShortDateString())" value="@Request["date"]" />
                    </li><commit_msg>Fixed an error, both html and behavior on Search page, 'date' field with double value attribute, only gets the default #161<commit_after>﻿@using WebMatrix.Data;
@{
    Layout = LcUrl.RenderLangPath + "_SiteLayout.cshtml";
    bool performSearch = false;
    // WelcomePopup is required again #514
    PageData["ShowWelcomePopup"] = true;
    
    PageData["Customer"] = LcData.UserInfo.GetUserRow();
    
    /* Getting search parameters */
    var serviceType = PageData["s"] = Request["s"];
    var serviceCat = PageData["c"] = Request["c"];
    var serviceLocation = PageData["location"] = Request["location"];
    var serviceDate = PageData["date"] = Request["date"];
    
    if (!String.IsNullOrWhiteSpace(serviceType) ||
        !String.IsNullOrWhiteSpace(serviceCat)) {
        performSearch = true;
    }
    bool categorizedResults = (String.IsNullOrEmpty(serviceCat) ? false : true);
    dynamic posrow = null;

    if (performSearch) {
        PageData["BodyClass"] = "search";
        PageData["IsHomePage"] = true; // consider true for now just all home script are shared
        Page.Title = "Search Results...";
        LcAssets.AddStyle(LcUrl.AppPath + "Styles/Search.css");
        
        // Building sql parameters:
        var LC_Term  = "%" + serviceType + "%";
        var LC_Cat = serviceCat;
        // Performing search:
        using (var db = Database.Open("sqlloco")) {
            if (categorizedResults) {
                // By category:
                var searchsql = "EXEC SearchPositionsByCategory @0, @1, @2, @3"; // "EXEC dbo.GetSearchResults @0,@1,@2,@3";
                posrow = db.Query(searchsql, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID(), LC_Cat, serviceLocation);
            } else {
                // By PositionSingular
                var searchsql = "EXEC dbo.SearchProvidersByPositionSingular @0,@1,@2";
                posrow = db.Query(searchsql, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID(), LC_Term);
            }
        }
    } else {
        PageData["BodyClass"] = "home";
        PageData["IsHomePage"] = true;
        Page.Title = "Make your life better.";
    }
}
@helper searchForm(){
        // We will return an array for the search-location autocomplete script
        string locationsCSV = "'San Francisco, CA', 'Other locations coming soon'";
        if (LcData.GetCurrentCountryID() == 2){
            locationsCSV = "'Barcelona', 'Other locations coming soon'";
        }
        PageData["InlineScript"] = @"
            window['LC'] = window['LC'] || {};
            LC.searchLocations = [ " + locationsCSV + @" ];
        ";
        <form id="homeSearch" method="get" class="lightform">
			<fieldset class="search-options">
                <ul>
                    <li class="search-service">
                        <label for="search-service">Search for a (e.g. Tutor, Gardener...)</label>
                        <input id="search-service" type="text" name="s" placeholder="Massage Therapist" value="@Request["s"]" />
                    </li>
                    <li class="search-location">
                        <label for="search-location">Where</label>
                        <input id="search-location" type="text" name="location" placeholder="San Francisco, CA" value="@Request["location"]" />
                    </li>
                    <li class="search-date">
                        <label for="search-date">When</label>
                        <input id="search-date" class="date-pick" type="text" name="date" value="@(Request["date"] ?? DateTime.Today.ToShortDateString())" />
                    </li>
{'fraction_non_alphanumeric': 0.14249790444258173, 'fraction_numerical': 0.004610226320201173, 'mean_word_length': 2.254090909090909, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4978088', 'n_tokens_mistral': 2023, 'n_tokens_neox': 1955, 'n_words': 445}