Permalink
Browse files

Fixed EF configuration for Auction class. Fixed #3.

  • Loading branch information...
1 parent 7334a7c commit 35932f68966aeb116bd3be6d7bd1c81e9c8a90aa @mrchief mrchief committed Apr 10, 2013
View
62 Ebuy.Common/Entities/Auction.cs
@@ -8,17 +8,26 @@
namespace Ebuy
{
- [MetadataType(typeof(Auction.Metadata))]
public class Auction : Entity<Guid>
{
- public virtual string Title { get; set; }
- public virtual string Description { get; set; }
- public virtual DateTime StartTime { get; set; }
- public virtual DateTime EndTime { get; set; }
- public virtual Currency StartPrice { get; set; }
- public virtual Currency CurrentPrice { get; set; }
-
- public Guid? WinningBidId { get; set; }
+ [Required, StringLength(500)]
+ public virtual string Title { get; set; }
+
+ [Required]
+ public virtual string Description { get; set; }
+
+ [Required]
+ public virtual DateTime StartTime { get; set; }
+
+ [Required]
+ public virtual DateTime EndTime { get; set; }
+
+ public Currency StartPrice { get; set; }
+
+ public Currency CurrentPrice { get; set; }
+
+ [ForeignKey("WinningBid")]
+ public Guid? WinningBidId { get; set; }
public virtual Bid WinningBid { get; private set; }
public bool IsCompleted
@@ -81,40 +90,7 @@ public Bid PostBid(User user, Currency bidAmount)
return bid;
}
-
-
- public class Metadata
- {
- [InverseProperty("Auction")]
- public object Bids;
-
- public object Categories;
-
- [Required]
- public object CurrentPrice;
-
- [Required]
- public object Description;
-
- [Required]
- public object EndTime;
-
- [InverseProperty("Selling")]
- public object Owner;
-
- [Required]
- [ForeignKey("Owner")]
- public object OwnerId;
-
- [Required]
- public object StartTime;
-
- [Required, StringLength(500)]
- public object Title;
-
- [ForeignKey("WinningBid")]
- public object WinningBidId;
- }
+
}
public class InvalidBidException : Exception
View
3 Ebuy.Website.Tests/Ebuy.Website.Tests.csproj
@@ -14,6 +14,8 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -109,6 +111,7 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.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">
View
9 Ebuy.Website/Views/Auctions/Auctions.cshtml
@@ -14,7 +14,14 @@
<section id="auction-details">
@* Render the first Auction using the Partial View on the server *@
- @Html.Partial("Auction", Model.FirstOrDefault())
+ @if (Model.Any())
+ {
+ @Html.Partial("Auction", Model.First())
+ }
+ else
+ {
+ <p>There are no auctions running right now. Try creating @Html.ActionLink("few", "Create").</p>
+ }
</section>
<script id="auction-template" type="text/x-template">

0 comments on commit 35932f6

Please sign in to comment.