c# - ASP.NET MVC - 将结束日期与开始日期与已保存在数据库中的开始日期进行比较
问题描述
我的系统将按如下方式工作:我有一个开始日期和一个结束日期。当您进行约会时,它会插入开始日期并保存此数据。进行新约会时,用户应输入上次约会的结束日期。
我的问题是我如何将他输入的这个最终日期与银行中已经存在的明星日期进行比较。
我的想法是结束日期不小于或等于星日期
I tried that way, but it will not work because I'm not picking the last start date in the dataBase to compare
public class finalDateoftheAppointmentCannotbeLessthantheStartDate : ISpecification<Appointment>
{
public bool IsSatisfiedBy(InfoAppointment infoAppointment)
{
return infoAppointment.EndDate<= infoApontamento.StarDate;
}
}
我使用存储库:
那是我的存储库类,也许我们可以在这里搜索最后日期进行比较
public virtual IEnumerable<TEntity> Buscar(Expression<Func<TEntity, bool>> predicate)
{
return Dbset.Where(predicate);
}
public class InfoApontamentosRepository : Repository<InfoAppointment>, IAppointmentRepository
{
public InfoAppointmentRepository(RveContext rveContext) : base(rveContext)
{
}
public InfoAppointment FindLastStartDate(Date date)
{
throw new NotImplementedException();
}
//example
public InfoApontamento FindByNumber(int number)
{
return Buscar(c => c.Atendimento == number).FirstOrDefault();
}
总结一下:如何获取数据库中保存的最后一个初始日期并与用户输入的结束日期进行比较,以防止结束日期小于或等于开始日期
解决方案
推荐阅读
- git - 在 HTTP 协议上设置 git 服务器时找不到
- python - 将 Tensorflow 张量从 C 移动到 python
- kubernetes - 为什么运行的 pod 数量减少了,而队列中的消息数量仍然很高?
- flutter - Flutter google登录id令牌无效值
- angular - 如何在 Angular 中有条件地路由和设置路径?
- c++ - zlib 解压返回 -3 (z_data_error)
- c++ - 如何去除图像中的遮罩区域?
- git - 将文件从包含一个文件的目录移动到另一个(重构)
- sql - sql中的历史数据和平均数据
- sql - 使用 SQL 查询返回 XML