Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reorganizing

  • Loading branch information...
commit 3d9de3a3f24626dd770d9c2aa74e6760fa8d21a0 1 parent 93c4b75
@jchadwick jchadwick authored
View
14 Ebuy.Common/App.config
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
+ <parameters>
+ <parameter value="v11.0" />
+ </parameters>
+ </defaultConnectionFactory>
+ </entityFramework>
+</configuration>
View
17 Ebuy.Common/DataAccess/EbuyDataContext.cs
@@ -0,0 +1,17 @@
+using System.Data.Entity;
+
+namespace Ebuy.DataAccess
+{
+ public class EbuyDataContext : DbContext
+ {
+ public DbSet<Auction> Auctions { get; set; }
+
+ public EbuyDataContext()
+ {
+#if(DEBUG)
+ var initializer = new DropCreateDatabaseIfModelChanges<EbuyDataContext>();
+ Database.SetInitializer(initializer);
+#endif
+ }
+ }
+}
View
67 Ebuy.Common/Ebuy.Common.csproj
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{F2B03BD9-D3AE-4F1C-BC2F-2CBEA3DE29DF}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Ebuy</RootNamespace>
+ <AssemblyName>Ebuy.Common</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile />
+ </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>
+ <Prefer32Bit>false</Prefer32Bit>
+ </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>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data.Entity" />
+ <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="Entities\Auction.cs" />
+ <Compile Include="DataAccess\EbuyDataContext.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ <None Include="packages.config" />
+ </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>
View
2  Ebuy.Common/Ebuy.Common.csproj.DotSettings
@@ -0,0 +1,2 @@
+<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+ <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Entities/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
View
14 Ebuy.Website/Models/Auction.cs → Ebuy.Common/Entities/Auction.cs
@@ -1,20 +1,8 @@
using System;
using System.ComponentModel.DataAnnotations;
-namespace Ebuy.Website.Models
+namespace Ebuy
{
- using System.Data.Entity;
-
- public class EbuyDataContext : DbContext
- {
- public DbSet<Auction> Auctions { get; set; }
-
- public EbuyDataContext()
- {
- Database.SetInitializer(new DropCreateDatabaseIfModelChanges<EbuyDataContext>());
- }
- }
-
public class Auction
{
public long Id { get; set; }
View
36 Ebuy.Common/Properties/AssemblyInfo.cs
@@ -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("Ebuy.Common")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Ebuy.Common")]
+[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("043c52b8-8c03-4480-a745-abc235fa6e2e")]
+
+// 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")]
View
4 Ebuy.Common/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="EntityFramework" version="5.0.0" targetFramework="net45" />
+</packages>
View
58 Ebuy.Website/App_Start/NinjectWebCommon.cs
@@ -0,0 +1,58 @@
+[assembly: WebActivator.PreApplicationStartMethod(typeof(Ebuy.Website.App_Start.NinjectWebCommon), "Start")]
+[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(Ebuy.Website.App_Start.NinjectWebCommon), "Stop")]
+
+namespace Ebuy.Website.App_Start
+{
+ using System;
+ using System.Web;
+
+ using Microsoft.Web.Infrastructure.DynamicModuleHelper;
+
+ using Ninject;
+ using Ninject.Web.Common;
+
+ public static class NinjectWebCommon
+ {
+ private static readonly Bootstrapper bootstrapper = new Bootstrapper();
+
+ /// <summary>
+ /// Starts the application
+ /// </summary>
+ public static void Start()
+ {
+ DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
+ DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
+ bootstrapper.Initialize(CreateKernel);
+ }
+
+ /// <summary>
+ /// Stops the application.
+ /// </summary>
+ public static void Stop()
+ {
+ bootstrapper.ShutDown();
+ }
+
+ /// <summary>
+ /// Creates the kernel that will manage your application.
+ /// </summary>
+ /// <returns>The created kernel.</returns>
+ private static IKernel CreateKernel()
+ {
+ var kernel = new StandardKernel();
+ kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
+ kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
+
+ RegisterServices(kernel);
+ return kernel;
+ }
+
+ /// <summary>
+ /// Load your modules or register your services here!
+ /// </summary>
+ /// <param name="kernel">The kernel.</param>
+ private static void RegisterServices(IKernel kernel)
+ {
+ }
+ }
+}
View
6 Ebuy.Website/Controllers/AuctionsController.cs
@@ -1,7 +1,7 @@
using System;
using System.Linq;
using System.Web.Mvc;
-using Ebuy.Website.Models;
+using Ebuy.DataAccess;
namespace Ebuy.Website.Controllers
{
@@ -12,7 +12,7 @@ public ActionResult Index(int page = 0, int size = 25)
{
var db = new EbuyDataContext();
var auctions = db.Auctions.OrderByDescending(x => x.EndTime).Skip(page * 25).Take(size);
- return View("Auctions", auctions);
+ return View("Auctions", auctions.ToArray());
}
[MultipleResponseFormats]
@@ -52,7 +52,7 @@ public ActionResult PartialAuction(long id)
public ActionResult Details(long id = 0)
{
- var auction = new Ebuy.Website.Models.Auction
+ var auction = new Auction
{
Id = id,
Title = "Brand new Widget 2.0",
View
18 Ebuy.Website/Ebuy.Website.csproj
@@ -40,6 +40,15 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
+ <Reference Include="Ninject">
+ <HintPath>..\packages\Ninject.3.0.1.10\lib\net45-full\Ninject.dll</HintPath>
+ </Reference>
+ <Reference Include="Ninject.Web.Common">
+ <HintPath>..\packages\Ninject.Web.Common.3.0.0.7\lib\net45-full\Ninject.Web.Common.dll</HintPath>
+ </Reference>
+ <Reference Include="Ninject.Web.Mvc">
+ <HintPath>..\packages\Ninject.MVC3.3.0.0.6\lib\net45-full\Ninject.Web.Mvc.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Entity" />
@@ -110,6 +119,9 @@
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
+ <Reference Include="WebActivator">
+ <HintPath>..\packages\WebActivator.1.5.1\lib\net40\WebActivator.dll</HintPath>
+ </Reference>
<Reference Include="WebMatrix.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.Data.2.0.20710.0\lib\net40\WebMatrix.Data.dll</HintPath>
@@ -159,6 +171,7 @@
<Compile Include="App_Start\AuthConfig.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
+ <Compile Include="App_Start\NinjectWebCommon.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\AccountController.cs" />
@@ -169,7 +182,6 @@
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Models\AccountModels.cs" />
- <Compile Include="Models\Auction.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -296,6 +308,10 @@
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Ebuy.Common\Ebuy.Common.csproj">
+ <Project>{f2b03bd9-d3ae-4f1c-bc2f-2cbea3de29df}</Project>
+ <Name>Ebuy.Common</Name>
+ </ProjectReference>
<ProjectReference Include="..\Ebuy.Mvc\Ebuy.Mvc.csproj">
<Project>{3ffe7a82-7e7d-42eb-a439-deaacbcfbfc6}</Project>
<Name>Ebuy.Mvc</Name>
View
2  Ebuy.Website/Views/Auctions/Auction.cshtml
@@ -1,4 +1,4 @@
-@model Ebuy.Website.Models.Auction
+@model Ebuy.Auction
<div class="title">@Model.Title</div>
<div class="overview">
View
4 Ebuy.Website/Views/Auctions/Auctions.cshtml
@@ -1,4 +1,4 @@
-@model IEnumerable<Ebuy.Website.Models.Auction>
+@model IEnumerable<Ebuy.Auction>
<h2>Auctions</h2>
<ul class="auctions">
@@ -14,7 +14,7 @@
<section id="auction-details">
@* Render the first Auction using the Partial View on the server *@
- @Html.Partial("Auction", Model.First())
+ @Html.Partial("Auction", Model.FirstOrDefault())
</section>
<script id="auction-template" type="text/x-template">
View
2  Ebuy.Website/Views/Auctions/Create.cshtml
@@ -1,4 +1,4 @@
-@model Ebuy.Website.Models.Auction
+@model Ebuy.Auction
@section scripts {
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
View
2  Ebuy.Website/Views/Auctions/Details.cshtml
@@ -1,4 +1,4 @@
-@model Ebuy.Website.Models.Auction
+@model Ebuy.Auction
@{
ViewBag.Title = "Details";
View
4 Ebuy.Website/packages.config
@@ -28,5 +28,9 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.5.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.6" targetFramework="net45" />
+ <package id="Ninject" version="3.0.1.10" targetFramework="net45" />
+ <package id="Ninject.MVC3" version="3.0.0.6" targetFramework="net45" />
+ <package id="Ninject.Web.Common" version="3.0.0.7" targetFramework="net45" />
+ <package id="WebActivator" version="1.5.1" targetFramework="net45" />
<package id="WebGrease" version="1.1.0" targetFramework="net45" />
</packages>
View
6 Ebuy.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ebuy.Website.Tests", "Ebuy.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ebuy.Mvc", "Ebuy.Mvc\Ebuy.Mvc.csproj", "{3FFE7A82-7E7D-42EB-A439-DEAACBCFBFC6}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ebuy.Common", "Ebuy.Common\Ebuy.Common.csproj", "{F2B03BD9-D3AE-4F1C-BC2F-2CBEA3DE29DF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -25,6 +27,10 @@ Global
{3FFE7A82-7E7D-42EB-A439-DEAACBCFBFC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FFE7A82-7E7D-42EB-A439-DEAACBCFBFC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FFE7A82-7E7D-42EB-A439-DEAACBCFBFC6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F2B03BD9-D3AE-4F1C-BC2F-2CBEA3DE29DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F2B03BD9-D3AE-4F1C-BC2F-2CBEA3DE29DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F2B03BD9-D3AE-4F1C-BC2F-2CBEA3DE29DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F2B03BD9-D3AE-4F1C-BC2F-2CBEA3DE29DF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Please sign in to comment.
Something went wrong with that request. Please try again.