Last active
December 17, 2015 06:09
-
-
Save Maarten88/5563702 to your computer and use it in GitHub Desktop.
Bootstrap compatible ASP.NET MVC4 EditorTemplate for DateAndTime class, using datepicker and timepicker controls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel.DataAnnotations; | |
using Auction.Web.Domain.Models; | |
using Auction.Web.Utility; | |
namespace Auction.Web.Areas.Seller.Models | |
{ | |
public class AuctionViewModel : Domain.Models.Auction | |
{ | |
public AuctionViewModel(Domain.Models.Auction auction) | |
: base(auction) | |
{ | |
} | |
public AuctionViewModel() | |
{ | |
// default values for new form | |
var now = DateTime.UtcNow; | |
this.Start = (now + TimeSpan.FromDays(1)).RoundDown(15); | |
this.End = (now + TimeSpan.FromDays(2)).RoundDown(15); | |
this.OpeningTime = new TimeSpan(8, 0, 0); | |
this.ClosingTime = new TimeSpan(22, 0, 0); | |
this.OpenOnSaturdays = true; | |
this.OpenOnSundays = false; | |
this.State = AuctionState.Planned; | |
this.Type = AuctionType.ExitAuction; | |
} | |
[Required] | |
[Display(Name = "Start datum en tijd")] | |
public DateAndTime StartDateAndTime | |
{ | |
get | |
{ | |
//return new DateAndTime((DateTime)this.Start); | |
return new DateAndTime((DateTime)this.Start.ToLocalAuctionTime()); | |
} | |
set | |
{ | |
this.Start = value.DateTime; | |
} | |
} | |
[Required] | |
[Display(Name = "Eind datum en tijd")] | |
public DateAndTime EndDateAndTime | |
{ | |
get | |
{ | |
//return new DateAndTime((DateTime)this.End); | |
return new DateAndTime((DateTime)this.End.Value.ToLocalAuctionTime()); | |
} | |
set | |
{ | |
this.End = value.DateTime; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment