如果这是我在下面尝试做的一个愚蠢的问题,请原谅。
这是我的行动:
public JsonResult CumLeadsParameters(CumLeadsReport cumLeads)
{
var weeks = (cumLeads.EndDate - cumLeads.StartDate).TotalDays / 7;
if (!(weeks > 0))
{
// means I have less than a week so calculate days and make it as a weeek and
var startDate = new DateTime(cumLeads.StartDate.Year,
cumLeads.StartDate.Month,
cumLeads.StartDate.Day, 0, 0, 0, 0);
var ts = new TimeSpan(23, 59, 59);
var endDate = startDate.AddDays(6.0).Date + ts;
var x = _retailerStatsRepository.GetAllRetailersForManufacturerCountrySelectedDates(
manufacturer.Id,
country.Id,
startDate,
endDate);
}
else
{
cumLeads.StartDate = new DateTime(cumLeads.StartDate.Year,
cumLeads.StartDate.Month,
cumLeads.StartDate.Day, 0, 0, 0, 0);
while (weeks > 0)
{
weekCounter++;
var ts = new TimeSpan(23, 59, 59);
cumLeads.EndDate = cumLeads.StartDate.AddDays(6.0).Date + ts;
var x = _retailerStatsRepository.GetAllRetailersForManufacturerCountrySelectedDates(
manufacturer.Id,
country.Id,
cumLeads.StartDate,
cumLeads.EndDate);
tuple.Add(new Tuple<int, IQueryable<RetailerStat>, DateTime, DateTime>(
weekCounter,
x,
cumLeads.StartDate,
cumLeads.EndDate));
}
}
}
/* 笔记*/
例如,我已经通过了 datecumLeads.StartDate
和cumLeads.EndDate
as2013-08-01 to 2013-08-12
然后我的 while 条件被满足了两次,当它第二次进入循环时,我不希望 date 被设置回01/08/2013
我startdate
想要的 as 08/08/2013 00:00:00:000
。
任何建议都会有所帮助。