Permalink
Browse files

Getting past object reference error while Creating a new Auction

  • Loading branch information...
1 parent 35932f6 commit 8542bce722f85b84716e38bcbd3f5473660e9728 @mrchief mrchief committed Apr 10, 2013
@@ -5,6 +5,9 @@ namespace Ebuy.DataAccess
public class EbuyDataContext : DbContext
{
public DbSet<Auction> Auctions { get; set; }
+ public DbSet<Bid> Bids { get; set; }
+ public DbSet<Category> Categories { get; set; }
+ public DbSet<User> User { get; set; }
public EbuyDataContext()
{
@@ -21,5 +24,7 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
.WithMany()
.WillCascadeOnDelete(false);
}
+
+
}
}
@@ -22,9 +22,9 @@ public class Auction : Entity<Guid>
[Required]
public virtual DateTime EndTime { get; set; }
- public Currency StartPrice { get; set; }
+ public virtual Currency StartPrice { get; set; }
- public Currency CurrentPrice { get; set; }
+ public virtual Currency CurrentPrice { get; set; }
[ForeignKey("WinningBid")]
public Guid? WinningBidId { get; set; }
@@ -59,6 +59,7 @@ public Auction()
Bids = new Collection<Bid>();
Categories = new Collection<Category>();
Images = new Collection<WebsiteImage>();
+ StartTime = DateTime.UtcNow;
}
public void FeatureAuction()
@@ -36,7 +36,7 @@ public Bid(User user, Auction auction, Currency price)
Timestamp = DateTime.Now;
}
- private Bid()
+ public Bid()
{
}
@@ -16,7 +16,7 @@ public CurrencyCode(string value) : this()
_value = value;
}
- private CurrencyCode()
+ public CurrencyCode()
{
}
@@ -60,7 +60,7 @@ public Currency(string currency)
Value = double.Parse(currency.Substring(1));
}
- private Currency()
+ public Currency()
{
}
@@ -1,4 +1,5 @@
-using System.Linq;
+using System;
+using System.Linq;
using System.Web.Mvc;
using Ebuy.DataAccess;
@@ -67,6 +68,7 @@ public ActionResult Create(Auction auction)
if (ModelState.IsValid)
{
var db = new EbuyDataContext();
+ auction.CurrentPrice = auction.StartPrice;
db.Auctions.Add(auction);
db.SaveChanges();
@@ -76,6 +78,22 @@ public ActionResult Create(Auction auction)
return View(auction);
}
+
+ //
+ // GET: /Test/Details/{guid}
+
+ public ActionResult Details(Guid id)
+ {
+ var db = new EbuyDataContext();
+ var auction = db.Auctions.Find(id);
+ if (auction == null)
+ {
+ return HttpNotFound();
+ }
+ return View(auction);
+ }
+
+
//
// GET: /Auctions/Edit/5
@@ -20,6 +20,8 @@
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -123,7 +125,7 @@
<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>
+ <HintPath>..\packages\WebActivator.1.5.3\lib\net40\WebActivator.dll</HintPath>
</Reference>
<Reference Include="WebMatrix.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
@@ -355,6 +357,7 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
+ <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">
@@ -16,6 +16,7 @@
@* Render the first Auction using the Partial View on the server *@
@if (Model.Any())
{
+ <h3>Auction Details</h3>
@Html.Partial("Auction", Model.First())
}
else
@@ -32,6 +32,6 @@
<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="WebActivator" version="1.5.3" targetFramework="net45" />
<package id="WebGrease" version="1.1.0" targetFramework="net45" />
</packages>

0 comments on commit 8542bce

Please sign in to comment.