Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Signum Framework Tutorials Part 2 – Southwind Logic

By , 15 Nov 2012
Northwind.zip
Northwind.bak
SignumFramework2.0-src.zip
signumframework-signumframework-c6436e1
.gitignore
Local.testsettings
README.md
Signum.Engine
ClassDiagram1.cd
Connection
DynamicQuery
Engine
Linq
ExpressionVisitor
Meta
Properties
Schema
Schema.cd
SchemaBuilder
SignumFramework.pfx
Signum.Entities
Attributes.cd
Basics
ClassDiagram1.cd
Diagram.cd
DynamicQuery
Tokens
Patterns
Properties
Reflection
Services
SignumFramework.pfx
Signum.Framework.vsmdi
Signum.Test
ClassDiagram1.cd
LinqProvider
Properties
Settings.settings
Signum.Utilities
DataStructures
IntervalDictionaries
ExpressionTrees
Properties
Reflection
SignumFramework.pfx
Synchronization
Signum.Web
ButtonBar
ControllerAttributes
Facades
HtmlHelpers
JSRenderer
LineHelpers
Lines
Mappings
PortableAreas
Repositories
Properties
Signum
Content
Controllers
Images
asc.gif
calendar.png
desc.gif
lineButtons.gif
sign_error.gif
Models
Scripts
Views
Widgets
SignumFramework.pfx
TypeContext
Widgets
Signum.Windows
Basics
Controls
ColorUtils
Converters
DynamicQuery
EntityControls
Facades
Fluent
Images
admin.png
alert.png
calendar.png
cancel.png
close.png
entity.png
find.png
forbidden.png
newColumn.png
newFilter.png
note.png
ok.png
pin.png
reload.png
save.png
star.png
Localization
MarkupExtensions
Properties
SignumFramework.pfx
Themes
Utilities
Widgets
SignumFrameworkSetup
logo.ico
signumFramework2.0.jpg
SignumFrameworkSetup.vdproj
Snippets
DroidSansMono.ttf
entity.snippet
entityWithName.snippet
expressionMethod.snippet
expressionMethodQuery.snippet
expressionProperty.snippet
field.snippet
fieldCreacion.snippet
fieldEuro.snippet
fieldInicioFin.snippet
fieldString.snippet
fiff.snippet
propiedad.snippet
RazorSingleFileGenerator.vsix
Signum.Fonts.vssettings
T4template
tran.snippet
Template
EntityControlTemplate
__TemplateIcon.ico
MyTemplate.vstemplate
SignumEntityControl.zip
Template
__TemplateIcon.ico
MyTemplate.vstemplate
ProjectName.Entities
__TemplateIcon.ico
MyTemplate.vstemplate
Properties
ProjectName.Load
__TemplateIcon.ico
MyTemplate.vstemplate
Properties
Settings.settings
ProjectName.Logic
__TemplateIcon.ico
MyTemplate.vstemplate
Properties
ProjectName.Web
__TemplateIcon.ico
Code
Content
smoothness
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Controllers
favicon.ico
Global.asax
MyTemplate.vstemplate
Properties
Settings.settings
Scripts
ServerCapri.svc
Views
Capri
Home
Shared
ProjectName.Windows
__TemplateIcon.ico
Controls
MyTemplate.vstemplate
Properties
Settings.settings
SignumFramework2ClientServer.zip
WizardProjectName
Test
Properties
Settings.settings
WizardProjectName
Isolated
Properties
SignumFramework.pfx
TraceAndTestImpact.testsettings
SignumFramework2Setup.zip
SignumFramework2Setup.msi
Southwind-Part2-Logic.zip
.gitignore
README.md
Southwind.vssscc
Southwind
Southwind.Entities
Properties
Southwind.Load
Properties
Settings.settings
Southwind.Logic
Properties
Southwind.Web
Code
Content
smoothness
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Controllers
favicon.ico
Global.asax
Properties
Settings.settings
Scripts
ServerSouthwind.svc
Views
Home
Shared
Southwind
Southwind.Windows
Controls
Properties
Settings.settings
Southwind.zip
Southwind.bak
@using Signum.Web.Properties
@using Signum.Entities.DynamicQuery
@using Signum.Engine.DynamicQuery
@using System.Configuration
@using Signum.Entities.Reflection
@using Signum.Web.Properties
@model Context
@{ 
    FindOptions findOptions = (FindOptions)ViewData[ViewDataKeys.FindOptions];
    QueryDescription queryDescription = (QueryDescription)ViewData[ViewDataKeys.QueryDescription];
    var entityColumn = queryDescription.Columns.Single(a => a.IsEntity);
    Type entitiesType = Reflector.ExtractLite(entityColumn.Type);
    Implementations implementations = entityColumn.Implementations;
    bool viewable = findOptions.View && (implementations != null || Navigator.IsNavigable(entitiesType, true));
}
<div id="@Model.Compose("divSearchControl")" 
     class="sf-search-control" 
     data-quickfilter-url="@Url.SignumAction("QuickFilter")"
     data-search-url="@Url.SignumAction("Search")"
     data-popup-save-url="@Url.SignumAction("TrySavePartial")"
     @(findOptions.EntityContextMenu ? " data-entity-ctx-menu-url=" + Url.SignumAction("GetContextualPanel") : "")
     >

    @Html.Hidden(Model.Compose("sfWebQueryName"), Navigator.ResolveWebQueryName(findOptions.QueryName), new { disabled = "disabled" })
    @Html.Hidden(Model.Compose("sfAllowMultiple"), findOptions.AllowMultiple.ToString(), new { disabled = "disabled" })
    @Html.Hidden(Model.Compose("sfView"), viewable, new { disabled = "disabled" })
    @Html.Hidden(Model.Compose("sfEntityTypeNames"), 
                               implementations == null ? Navigator.ResolveWebTypeName(entitiesType) :
                                                      implementations.IsByAll ? "[All]" :
                                                      ((ImplementedByAttribute)implementations).ImplementedTypes.ToString(t => Navigator.ResolveWebTypeName(t), ","), 
                               new { disabled = "disabled" })
    
    @if(findOptions.SearchOnLoad)
    {
        <script type="text/javascript">
            $(document).ready(function () { { SF.FindNavigator.searchOnLoad('@Model.ControlID'); } });
            </script>    
    }
    
    @{
        bool filtersAlwaysHidden = findOptions.FilterMode == FilterMode.AlwaysHidden || findOptions.FilterMode == FilterMode.OnlyResults;
        bool filtersVisible = findOptions.FilterMode == FilterMode.Visible;
     }
    
    <div id="@Model.Compose("divFilters")" style="display:@(filtersAlwaysHidden ? "none" : "block")" >
        @{ Html.RenderPartial(Navigator.Manager.FilterBuilderView, ViewData);}
    </div>
    
    @if (!filtersAlwaysHidden)
    {
        @Html.Href("",
                (filtersVisible ? Resources.Signum_hideFilters : Resources.Signum_showFilters),
                "",
                (filtersVisible ? Resources.Signum_hideFilters : Resources.Signum_showFilters),
                "sf-query-button" + " sf-filters-header" + (filtersVisible ? "" : " close"),
                new Dictionary<string, object> 
                { 
                    { "onclick", "new SF.FindNavigator({{prefix: '{0}'}}).toggleFilters(this)".Formato(Model.ControlID) },
                    { "data-icon", filtersVisible ? "ui-icon-triangle-1-n" : "ui-icon-triangle-1-e" }
                })
    }
    
    <div class="sf-query-button-bar" style="display:@((findOptions.FilterMode != FilterMode.OnlyResults) ? "block" : "none")">
        <button type="submit" class="sf-query-button sf-search" data-icon="ui-icon-search" id="@Model.Compose("qbSearch")" onclick="@("new SF.FindNavigator({{prefix:'{0}',searchControllerUrl:'{1}'}}).search();return false;".Formato(Model.ControlID, Url.SignumAction("Search")))">@Resources.Search</button>
        @if (findOptions.Create && (implementations != null || Navigator.IsCreable(entitiesType, true)) && viewable)
        {
            bool hasManyImplementations = implementations != null && !implementations.IsByAll && ((ImplementedByAttribute)implementations).ImplementedTypes.Length > 1;
            string creating = findOptions.Creating.HasText() ? findOptions.Creating :
                "SF.FindNavigator.create({{prefix:'{0}',controllerUrl:'{1}'}},'{2}');return false;".Formato(
                    Model.ControlID, 
                    Url.SignumAction(string.IsNullOrEmpty(Model.ControlID) ? "Create" : "PopupCreate"),
                    hasManyImplementations ? RouteHelper.New().SignumAction("GetTypeChooser") : "");
            <a class="sf-query-button" data-icon="ui-icon-plusthick" data-text="false" id="@Model.Compose("qbSearchCreate")" onclick="@creating">@Resources.Search_Create</a>
        }
        @ButtonBarQueryHelper.GetButtonBarElementsForQuery(this.ViewContext, findOptions.QueryName, entitiesType, Model.ControlID).ToString(Html)
    </div>
    @if (findOptions.FilterMode != FilterMode.OnlyResults)
    {
        <div class="clearall">
        </div>
    }
    <div id="@Model.Compose("divResults")" class="ui-widget ui-corner-all sf-search-results-container">
        <table id="@Model.Compose("tblResults")" class="sf-search-results">
            <thead class="ui-widget-header ui-corner-top">
                <tr>
                    @if (findOptions.AllowMultiple.HasValue)
                    {
                        <th class="ui-state-default th-col-selection">
                            @if (findOptions.AllowMultiple.Value)
                            {
                                @Html.CheckBox(Model.Compose("cbSelectAll"), false, new { onclick = "javascript:new SF.FindNavigator({{prefix:'{0}'}}).toggleSelectAll();".Formato(Model.ControlID) })
                            }
                        </th>
                    }
                    @if (viewable)
                    {
                        <th class="ui-state-default th-col-entity">
                        </th>
                    }
                    @{List<Column> columns = findOptions.MergeColumns(); }
                    @foreach (var col in columns)
                    {
                        var order = findOptions.OrderOptions.FirstOrDefault(oo => oo.Token.FullKey() == col.Name);
                        OrderType? orderType = null;
                        if (order != null)
                        {
                            orderType = order.OrderType;
                        }
                        <th class="ui-state-default @((orderType == null) ? "" : (orderType == OrderType.Ascending ? "sf-header-sort-down" : "sf-header-sort-up"))">
                            <input type="hidden" value="@col.Name" />
                            @col.DisplayName
                        </th>
                    }
                </tr>
            </thead>
            <tbody class="ui-widget-content">
                <tr>
                    <td colspan="@(columns.Count + (viewable ? 1 : 0) + (findOptions.AllowMultiple.HasValue ? 1 : 0))">@Resources.Signum_noResults</td>
                </tr>
            </tbody>
            <tfoot>
            </tfoot>
        </table>
        
        <div class="ui-widget-header ui-corner-bottom sf-search-footer" style="display:@((findOptions.FilterMode != FilterMode.OnlyResults) ? "block" : "none")">
            @Html.Span(null, Resources.SearchControl_ShowNRows_Show)
            @{ int? top = findOptions.Top ?? (findOptions.TopEmpty ? null : Navigator.Manager.QuerySettings.GetOrThrow(findOptions.QueryName, "Missing QuerySettings for QueryName {0}").Top);}
            @HtmlHelperExtenders.InputType("text", Model.Compose("sfTop"), top.TryToString(), new Dictionary<string, object> { { "size", "3" }, { "onkeydown", "return SF.InputValidator.isNumber(event)" } })
            @Html.Span(null, Resources.SearchControl_ShowNRows_Rows + ".")
            @Html.Span(Model.Compose("rowsFoundCount"), "0", "rows-found-count")
            @Html.Span(null, Resources.SearchControl_RowsFound, "rows-found-count")

            @Html.Hidden(Model.Compose("sfOrders"), findOptions.OrderOptions.IsEmpty() ? "" :
                    (findOptions.OrderOptions.ToString(oo => (oo.OrderType == OrderType.Ascending ? "" : "-") + oo.Token.FullKey(), ";") + ";"))
        </div>
    </div>
</div>
<script type="text/javascript">
    new SF.FindNavigator({ prefix: "@Model.ControlID" }).initialize();
</script>

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

About the Author

Olmo del Corral
Software Developer (Senior) Signum Software
Spain Spain
I'm Computer Scientist, one of the founders of Signum Software, and the lead developer behind Signum Framework.
 
www.signumframework.com
 
I love programming in C#, Linq, Compilers, Algorithms, Functional Programming, Computer Graphics, Maths...

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 15 Nov 2012
Article Copyright 2011 by Olmo del Corral
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid