namespace MP.Core.DTO { public class EventDto { public string CodTipo { get; set; } = ""; /// /// Idx univoco evento /// public int IdxEv { get; set; } = 0; #if false public int IdxDipendente { get; set; } = 0; public string CognomeNome { get; set; } = ""; public bool Conf { get; set; } = false; public bool IsCompany { get; set; } = false; #endif public string Abbrev { get; set; } = ""; public string Titolo { get; set; } = ""; public string Descrizione { get; set; } = ""; public string Tooltip { get; set; } = ""; public DateTime DtStart { get; set; } = DateTime.Today.AddHours(9); public DateTime DtEnd { get; set; } = DateTime.Today.AddHours(17); public string Note { get; set; } = ""; public bool IsDraggable { get; set; } = false; public bool IsExpired { get; set; } = false; public bool IsPlanned { get; set; } = true; public EventDto Clone() { return new EventDto() { CodTipo = this.CodTipo, IdxEv = this.IdxEv, #if false IdxDipendente = this.IdxDipendente, CognomeNome = this.CognomeNome, Conf = this.Conf, IsCompany = this.IsCompany, #endif Abbrev = this.Abbrev, Titolo = this.Titolo, Descrizione = this.Descrizione, Tooltip = this.Tooltip, DtStart = this.DtStart, DtEnd = this.DtEnd, Note = this.Note, IsDraggable = this.IsDraggable, IsPlanned = this.IsPlanned, IsExpired = this.IsExpired }; } public string Durata { get { string answ = "-"; var durata = DtEnd.Subtract(DtStart); if (CodTipo == "FER") { answ = $"{durata.TotalDays + 1:N0}gg"; } else { answ = $"{durata.TotalHours:N1}h"; } return answ; } } public static string DateForm(string Tipo, DateTime DtEvent) { return (Tipo == "PERM" || Tipo == "104") ? $"{DtEvent:HH:mm}" : $"{DtEvent:ddd yyyy-MM-dd}"; } public string Color { get => calcColor(CodTipo, IsPlanned, IsExpired); } public string? ForeColor { get => calcText(CodTipo, IsPlanned, IsExpired); } private string calcColor(string codTipo, bool isPlanned, bool isExpired) { string answ = "#EDEDED"; switch (codTipo) { case "Saomad": answ = isExpired ? "#CDE0CD" : isPlanned ? "#11DD44" : "#D0F5DD"; break; case "Essetre": answ = isExpired ? "#AB9898" : isPlanned ? "#AD1919" : "#CD6767"; break; default: answ = isExpired ? "#EEDD11" : isPlanned ? "#11CD44" : "#AAFFCD"; break; } return answ; } private string calcText(string codTipo, bool isPlanned, bool isExpired) { string answ = "#EDEDED"; switch (codTipo) { case "Saomad": answ = isExpired ? "#000000" : isPlanned ? "#000000" : "#555555"; break; case "Essetre": answ = isExpired ? "#000000" : isPlanned ? "#EEFF69" : "#D3E817"; break; default: answ = isExpired ? "#000000" : isPlanned ? "#FFFFFF" : "#000000"; break; } return answ; } } }