您的位置:首页 > 编程语言 > ASP

Pro Aspnet MVC 4读书笔记(2) - The MVC Pattern

2014-01-21 08:22 281 查看
Listing 3-1. The C# Auction Domain Model

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcPattern.Models
{
public class Item
{
public int ItemID { get; private set; } // The unique key
public string Title { get; set; }
public string Description { get; set; }
public DateTime AuctionEndDate { get; set; }
public IList<Bid> Bids { get; set; }

public Item()
{
Bids = new List<Bid>();
}

public void AddBid(Member member, Decimal amount)
{
if (Bids.Count == 0 || amount > Bids.Max(e => e.BidAmount))
{
Bids.Add(new Bid()
{
BidAmount = amount,
DatePlaced = DateTime.Now,
Member = member
});
}
else
{
throw new InvalidOperationException("Bid amount too low");
}
}
}
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: