using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Core { public class SelectData { #region Public Properties public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1); public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7); #endregion Public Properties #region Public Methods /// /// Inizializzazione con periodo e arrotondamento /// /// /// Num giorni PREVIOUS (indietro) per start /// public static SelectData Init(int minRound, int numDayPrev) { // se numDayPrev è < 0 --> start oggi e va al futuro int dayOffset = numDayPrev > 0 ? 1 : -numDayPrev; DateTime endRounded = DateTime.Today.AddDays(dayOffset); SelectData answ = new SelectData() { DateEnd = endRounded, DateStart = endRounded.AddDays(-Math.Abs(numDayPrev)) }; return answ; } public override bool Equals(object obj) { if (!(obj is SelectData item)) return false; if (DateEnd != item.DateEnd) return false; if (DateStart != item.DateStart) return false; return true; } public override int GetHashCode() { return base.GetHashCode(); } #endregion Public Methods } }