hanyadikhetvan-dotnethf/HanyadikHetVan/DTO/WeeklyTimeSpanDTO.cs

30 lines
778 B
C#
Raw Normal View History

2021-05-19 04:33:53 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace HanyadikHetVan.DTO
{
public class WeeklyTimeSpanDTO
{
public int Id { get; set; }
public DateTime Startdate { get; set; }
public virtual ICollection<PauseDTO> Pauses { get; set; }
2021-05-19 17:56:56 +02:00
public virtual ICollection<FunFactDTO> FunFacts { get; set; }
2021-05-19 04:33:53 +02:00
public int CurrentWeek
{
get
{
TimeSpan allPause = this.Pauses.Aggregate(TimeSpan.Zero, (sumSoFar, nextPause) => sumSoFar + (nextPause.Enddate - nextPause.Startdate));
TimeSpan wtsLength = DateTime.Now - this.Startdate;
return (wtsLength - allPause).Days / 7;
}
}
}
}