Files
MileageTraker/Web/Attributes/DenyPreviousMonthDateAttribute.cs
T
poprhythm 9c2149d52c Add cancel button for edit log.
Disable edit button for past month
Format gas correctly
2014-01-21 11:30:17 -05:00

25 lines
719 B
C#

using System;
using System.ComponentModel.DataAnnotations;
using MileageTraker.Web.Models;
namespace MileageTraker.Web.Attributes
{
public class DenyPreviousMonthDateAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
var date = DateTime.Parse(value.ToString());
return date.Date >= GetCutoff();
}
private static DateTime GetCutoff()
{
return DomainRules.GetLogEntryCutoff();
//var today = DateTime.Today;
//return today.AddMonths(-1).AddDays(-today.Day + 1); // last two months
//if (today.Day > 10)
// return today.AddDays(-today.Day); // beginning of this month
//return today.AddMonths(-1).AddDays(-today.Day); // beginning of previous month
}
}
}