本文介绍了如何比较两个议程项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想比较两个AgendaEvent。
我有这个:
Hi everybody,
I want to compare two agendaEvent with each other.
I have this:
<pre lang="cs">public bool IsOverlapping(AgendaEventViewModel viewModel, AgendaEventViewModel newItem)
{
bool isOverlapping = false;
// ReservationModel r = new ReservationModel(int.Parse(viewModel.id));
DateTime? begin = DateTime.Parse(viewModel.start);
DateTime? end = DateTime.Parse(viewModel.end);
//DateTime? begin2 = DateTime.Parse(newEvent.start);
//DateTime? end2 = DateTime.Parse(newEvent.end);
//DateTime dataToCheck;
//newItem = new AgendaEventViewModel();
DateTime? begin2 = DateTime.Parse(newItem.start);
DateTime? end2 = DateTime.Parse(newItem.end);
// TODO: Check if Event is Overlapping with other events :) Dynamic RoomRules Check should implemented here
if (begin == begin2)
{
this.ShowMessage(Message.Type.Info, Resources.AgendaEvent.IsOverlapping);
isOverlapping = true;
}
return isOverlapping;
}
但是现在开始和开始2是相同的
我有一个agendaEventViewModel,但是如果你想添加一个其他议程项目,则不允许将它放在相同范围内的同一日期
And如果我这样做:
But now begin and begin2 are the same
I have one agendaEventViewModel but if you want to add a other agenda item, then it is not allowed to place it on the same date in the same range
And If I do this:
<pre lang="cs">public bool IsOverlapping(List<AgendaEventViewModel> viewModel, AgendaEventViewModel newItem)
{
bool isOverlapping = false;
// ReservationModel r = new ReservationModel(int.Parse(viewModel.id));
//DateTime? begin = DateTime.Parse(viewModel.start);
//DateTime? end = DateTime.Parse(viewModel.end);
//DateTime? begin2 = DateTime.Parse(newEvent.start);
//DateTime? end2 = DateTime.Parse(newEvent.end);
//DateTime dataToCheck;
//newItem = new AgendaEventViewModel();
DateTime? begin2 = DateTime.Parse(newItem.start);
DateTime? end2 = DateTime.Parse(newItem.end);
// TODO: Check if Event is Overlapping with other events :) Dynamic RoomRules Check should implemented here
if (viewModel.Any(m => DateTime.Parse( m.start) == DateTime.Parse(newItem.start)))
{
this.ShowMessage(Message.Type.Info, Resources.AgendaEvent.IsOverlapping);
isOverlapping = true;
}
return isOverlapping;
}
#endregion
viewmodel为null
这是我的AgendaEventViewModel:
viewmodel is null
This is my AgendaEventViewModel:
<pre lang="cs">public class AgendaEventViewModel
{
public string ReturnUrl { get; set; }
public string id { get; set; }
public int? funeralId { get; set; }
public int? reservationId { get; set; }
public int? roomId { get; set; }
[Display(Name = "Title", ResourceType = typeof(Resources.AgendaEvent))]
public string title { get; set; }
[Display(Name = "Start", ResourceType = typeof(Resources.AgendaEvent))]
public string start { get; set; }
[Display(Name = "End", ResourceType = typeof(Resources.AgendaEvent))]
public string end { get; set; }
public string top { get; set; }
public string left { get; set; }
public List<RoomItemModel> RoomItems { get; set; }
public List<CateringItemModel> CateringItems { get; set; }
[Display(Name = "SeatingCapacity", ResourceType = typeof(Resources.AgendaEvent))]
public int? SeatingCapacity { get; set; } //Max Room SeatingCapacity
[Display(Name = "ExpectedSeatingCapacity", ResourceType = typeof(Resources.AgendaEvent))]
public int? ExpectedSeatingCapacity { get; set; } // User Chosen
}
每次begin2覆盖开始时问题都是dat。所以我甚至无法提出一个议程项目
The problem is dat every time begin2 overwrites begin. So I cant even put one agenda item
推荐答案
return (begin <= end2) && (begin2 <= end);
这篇关于如何比较两个议程项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!