You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/Teacher/TeacherExt/Controllers/AjaxController.cs

41 lines
1.3 KiB

using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
namespace TeacherExt.Controllers
{
public class AjaxController : Controller
{
public IActionResult JobAsMaxTitleDate(DateTime? jobAsMaxTitleDate, bool? isJobAsMaxTitle)
{
if (isJobAsMaxTitle.HasValue && isJobAsMaxTitle.Value && !jobAsMaxTitleDate.HasValue)
{
return Json("以最高职称聘任的,必须填写聘任时间");
}
return this.ValidDate();
}
public IActionResult ValidDate()
{
if (Request.Query.Keys.Any())
{
var input = Request.Query.FirstOrDefault().Value.ToString();
if (!string.IsNullOrEmpty(input))
{
if (DateTime.TryParse(input, out var date))
{
if (date > DateTime.Now.AddDays(1))
{
return Json("日期不能大于当前时间");
}
else if (date < DateTime.Now.AddYears(-100))
{
return Json("日期不能小于当前时间100年");
}
}
}
}
return Json(true);
}
}
}