Pro Aspnet MVC 4读书笔记(2) - The MVC Pattern
2014-01-21 08:22
281 查看
Listing 3-1. The C# Auction Domain Model
View Code
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
相关文章推荐
- Using the Repository Pattern with ASP.NET MVC and Entity Framework
- [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 1. Creating the Project 创建项目
- [译]Pro ASP.NET MVC 3 Framework 3rd Edition (Chapter 20 JQuery) 1. Creating the Project 创建项目
- [转]Using the Repository Pattern with ASP.NET MVC and Entity Framework
- 【Pro ASP.NET MVC 3 Framework】.学习笔记.9.SportsStore:Securing the Administration Features
- Pro Aspnet MVC 4读书笔记(5) - Essential Tools for MVC
- How to achive the CRUD in ASP.NET MVC(VS2010)
- Introduction to ASP.NET's Model View Controller (MVC) Design Pattern
- Pro ASP.NET Core MVC(四)【C#关键特征】
- ASP.NET MVC报错: Multiple types were found that match the controller named
- Scaffold your ASP.NET MVC 3 project with the MvcScaffolding package
- Pro ASP.NET MVC - [3]Prerequisites(前提) - [2]Domain Modeling
- NU1002 The dependency Microsoft.AspNet.Mvc 5.2.3 in project dotnetstarter does not support framework
- [转]Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application (3 of 10)
- FineUIPro/Mvc/Core/JS v4.2.0 发布了(老牌ASP.NET控件库,WebForms,ASP.NET MVC,Core,JavaScript)!
- 好书推荐《Pro ASP.NET MVC 3 Framework 3rd Edition》
- How to Choose the Best Way to Pass Multiple Models in ASP.NET MVC
- ASP.NET MVC - how to make users confirm the delete
- 电子书下载:Pro ASP.NET MVC Framework