【发布时间】:2014-03-11 10:12:06
【问题描述】:
我正在用 ASP.NET MVC 构建拍卖系统。
如何让我的项目类的状态在结束日期过后显示“已完成”。
到目前为止,我已经创建了 Item 模型:
public class Item
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ItemId { get; set; }
[StringLength(100, ErrorMessage = "The {0} must be between {1} and {2} characters length", MinimumLength = 6)]
public string Title { get; set; }
[DataType(DataType.DateTime)]
public DateTime StartDate { get; set; }
[DataType(DataType.DateTime)]
public DateTime EndDate { get; set; }
public decimal StartingPrice { get; set; }
[StringLength(4000, ErrorMessage = "Description must be no longer than {1}")]
public string Description { get; set; }
public string Image { get; set; }
public string Status { get; set; }
public virtual UserProfile UserProfile { get; set; }
public virtual ICollection<Bid> Bids { get; set; }
}
和一个 ViewModel:
public class ViewItemViewModel
{
// [HiddenInput(DisplayValue = false)]
public int ItemId { get; set; }
public string Title { get; set; }
private DateTime endDate;
[Required]
[DataType(DataType.DateTime)]
public DateTime EndDate
{
get { return endDate; }
set
{
TimeSpan span = (value - DateTime.Now);
TimeLeft = String.Format("{0} d, {1} h, {2} m, {3} s left", span.Days, span.Hours, span.Minutes, span.Seconds);
endDate = value;
}
}
public string TimeLeft { get; private set; }
[StringLength(4000, ErrorMessage = "Description must be no longer than {1}")]
public string Description { get; set; }
public string Image { get; set; }
}
【问题讨论】:
-
到目前为止您尝试过什么?
-
看看这个 SO 帖子中的答案以获得一些想法......stackoverflow.com/questions/7369897/…
标签: c# asp.net sql .net asp.net-mvc