Permalink
Browse files

Initial commit.

  • Loading branch information...
primaryobjects committed Feb 17, 2012
0 parents commit 37cb8096867f3cd2eb8d79fc05aae14e14138858
Showing with 1,247 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +29 −0 SearchResultsPaging.Managers/HelperManager.cs
  3. +36 −0 SearchResultsPaging.Managers/Properties/AssemblyInfo.cs
  4. +48 −0 SearchResultsPaging.Managers/SearchManager.cs
  5. +62 −0 SearchResultsPaging.Managers/SearchResultsPaging.Managers.csproj
  6. +53 −0 SearchResultsPaging.Managers/TreasureManager.cs
  7. +29 −0 SearchResultsPaging.Types/PagingModel.cs
  8. +36 −0 SearchResultsPaging.Types/Properties/AssemblyInfo.cs
  9. +22 −0 SearchResultsPaging.Types/SearchModel.cs
  10. +56 −0 SearchResultsPaging.Types/SearchResultsPaging.Types.csproj
  11. +28 −0 SearchResultsPaging.Types/Treasure.cs
  12. +32 −0 SearchResultsPaging.sln
  13. +31 −0 SearchResultsPaging/Controllers/HomeController.cs
  14. +1 −0 SearchResultsPaging/Global.asax
  15. +37 −0 SearchResultsPaging/Global.asax.cs
  16. +273 −0 SearchResultsPaging/Helpers/HtmlHelperExtensions.cs
  17. +35 −0 SearchResultsPaging/Properties/AssemblyInfo.cs
  18. +136 −0 SearchResultsPaging/SearchResultsPaging.csproj
  19. +28 −0 SearchResultsPaging/SearchResultsPaging.csproj.user
  20. +12 −0 SearchResultsPaging/Styles/Style.css
  21. +11 −0 SearchResultsPaging/Views/Controls/SearchPaging.cshtml
  22. +11 −0 SearchResultsPaging/Views/Controls/SearchResults.cshtml
  23. +26 −0 SearchResultsPaging/Views/Home/Index.cshtml
  24. +15 −0 SearchResultsPaging/Views/Shared/Error.cshtml
  25. +12 −0 SearchResultsPaging/Views/Shared/_Layout.cshtml
  26. +58 −0 SearchResultsPaging/Views/Web.config
  27. +3 −0 SearchResultsPaging/Views/_ViewStart.cshtml
  28. +30 −0 SearchResultsPaging/Web.Debug.config
  29. +31 −0 SearchResultsPaging/Web.Release.config
  30. +54 −0 SearchResultsPaging/Web.config
@@ -0,0 +1,12 @@
+*.cache
+*.dll
+*.pdb
+*.txt
+*.suo
+*.exe
+*.exe.config
+*.exe.manifest
+!README.txt
+!lib/*.dll
+!robots.txt
+*.svclog
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SearchResultsPaging.Managers
+{
+ public class HelperManager
+ {
+ public static Random Random = new Random((int)DateTime.Now.Ticks);
+
+ public static string CreateRandomName(string[] firstNameList, string[] lastNameList)
+ {
+ // Generate a random Id from 0-99.
+ int randomId = Random.Next(100);
+
+ // Pad the Id to be 2 digits (01, 10, 99, etc).
+ string randomString = randomId.ToString().PadLeft(2, '0');
+
+ // Take the left digit to use as an index // for the first name and the right digit to use as an index for the last name.
+ int leftIndex = Convert.ToInt32(randomString[0].ToString());
+ int rightIndex = Convert.ToInt32(randomString[1].ToString());
+
+ string name = firstNameList[leftIndex] + " " + lastNameList[rightIndex];
+
+ return name;
+ }
+ }
+}
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SearchResultsPaging.Managers")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SearchResultsPaging.Managers")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1a4fb1d8-2255-4af0-a31f-ace90b0cb1cc")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SearchResultsPaging.Types;
+
+namespace SearchResultsPaging.Managers
+{
+ public static class SearchManager
+ {
+ public static List<Treasure> GenerateTreasure(int count)
+ {
+ List<Treasure> treasureList = new List<Treasure>();
+
+ for (int i = 0; i < count; i++)
+ {
+ treasureList.Add(TreasureManager.CreateRandom());
+ }
+
+ return treasureList;
+ }
+
+ public static SearchModel Search(List<Treasure> treasureList, int page, int pageSize)
+ {
+ SearchModel searchModel = new SearchModel();
+
+ // Set paging information.
+ searchModel.CurrentPage = page;
+ searchModel.CurrentMin = (page * pageSize) - pageSize + 1;
+ searchModel.CurrentMax = searchModel.CurrentMin + pageSize - 1;
+ searchModel.PageSize = pageSize;
+ searchModel.TotalResults = treasureList.Count;
+
+ // Set search points.
+ int start = (page * pageSize) - pageSize;
+ int end = start + pageSize;
+
+ // Run search.
+ for (int i = start; i < end; i++)
+ {
+ searchModel.TreasureList.Add(treasureList[i]);
+ }
+
+ // Return results.
+ return searchModel;
+ }
+ }
+}
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{118B8004-2F72-4078-93DA-4470C96AB09C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SearchResultsPaging.Managers</RootNamespace>
+ <AssemblyName>SearchResultsPaging.Managers</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="HelperManager.cs" />
+ <Compile Include="SearchManager.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TreasureManager.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\SearchResultsPaging.Types\SearchResultsPaging.Types.csproj">
+ <Project>{2BB72FA6-5385-474E-AECD-069E906D9073}</Project>
+ <Name>SearchResultsPaging.Types</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SearchResultsPaging.Types;
+
+namespace SearchResultsPaging.Managers
+{
+ public static class TreasureManager
+ {
+ #region Names
+
+ private static string[] treasureFirstName = new string[10]
+ {
+ "Glittering",
+ "Sparkling",
+ "Golden",
+ "Dark",
+ "Evil",
+ "Poisonous",
+ "Magic",
+ "Silver",
+ "Radiant",
+ "Valiant"
+ };
+
+ private static string[] treasureLastName = new string[10]
+ {
+ "Helm",
+ "Glove",
+ "Box",
+ "Disc",
+ "Rod",
+ "Coin",
+ "Goblet",
+ "Sword",
+ "Arrow",
+ "Key"
+ };
+
+ #endregion
+
+ public static Treasure CreateRandom()
+ {
+ Treasure treasure = new Treasure();
+
+ treasure.Name = HelperManager.CreateRandomName(treasureFirstName, treasureLastName);
+ treasure.Value = HelperManager.Random.Next(1, 500);
+
+ return treasure;
+ }
+ }
+}
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SearchResultsPaging.Types
+{
+ public class PagingModel
+ {
+ public int TotalResults { get; set; }
+ public int CurrentPage { get; set; }
+ public int PageSize { get; set; }
+ public int CurrentResultsMax { get; set; }
+ public int CurrentResultsMin { get; set; }
+
+ public PagingModel()
+ {
+ }
+
+ public PagingModel(int totalResults, int currentPage, int pageSize, int currentResultsMax, int currentResultsMin)
+ {
+ TotalResults = totalResults;
+ CurrentPage = currentPage;
+ PageSize = pageSize;
+ CurrentResultsMax = currentResultsMax;
+ CurrentResultsMin = currentResultsMin;
+ }
+ }
+}
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SearchResultsPaging.Types")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SearchResultsPaging.Types")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("41e963a7-af17-46d2-ad2f-ccaa1ba51249")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SearchResultsPaging.Types
+{
+ public class SearchModel
+ {
+ public List<Treasure> TreasureList { get; set; }
+ public int TotalResults { get; set; }
+ public int CurrentPage { get; set; }
+ public int PageSize { get; set; }
+ public int CurrentMin { get; set; }
+ public int CurrentMax { get; set; }
+
+ public SearchModel()
+ {
+ TreasureList = new List<Treasure>();
+ }
+ }
+}
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2BB72FA6-5385-474E-AECD-069E906D9073}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SearchResultsPaging.Types</RootNamespace>
+ <AssemblyName>SearchResultsPaging.Types</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="PagingModel.cs" />
+ <Compile Include="SearchModel.cs" />
+ <Compile Include="Treasure.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
Oops, something went wrong.

0 comments on commit 37cb809

Please sign in to comment.