using Gestor.Model.Common; using Gestor.Model.Domain.Generic; using Gestor.Model.Domain.Seguros; using Gestor.Model.Helper; using Gestor.Model.Resources; using Gestor.Model.Validation; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.CompilerServices; namespace Gestor.Model.Domain.Ferramentas { public class Trilha : DomainBase, IDomain { public bool Ativo { get; set; } public string Descricao { get; set; } public List Fases { get; set; } public TipoTrilha Tipo { get; set; } public string Titulo { get; set; } [JsonIgnore] public Func>> ValidationEvent { get { Trilha trilha = this; return new Func>>(trilha.Validate); } } public Trilha() { } public List Log() { List tupleLists = new List() { new TupleList() { Tuples = new ObservableCollection>() { new Tuple("TÍTULO DA TRILHA", (string.IsNullOrWhiteSpace(this.Titulo) ? "" : this.Titulo), ""), new Tuple("DESCRIÇÃO DA TRILHA", (string.IsNullOrWhiteSpace(this.Descricao) ? "" : this.Descricao), ""), new Tuple("ATIVO", (this.Ativo ? "SIM" : "NÃO"), "") } } }; ObservableCollection> observableCollection = new ObservableCollection>() { new Tuple("FASES$", "", "") }; if (this.Fases != null) { foreach (Fase fase in this.Fases) { observableCollection.Add(new Tuple(string.Format(" FASE {0}$", this.Fases.IndexOf(fase) + 1), "", "")); observableCollection.Add(new Tuple(" TÍTULO DA FASE", (string.IsNullOrWhiteSpace(fase.Titulo) ? "" : fase.Titulo), "")); observableCollection.Add(new Tuple(" DESCRIÇÃO DA FASE", (string.IsNullOrWhiteSpace(fase.Descricao) ? "" : fase.Descricao), "")); foreach (Tarefa tarefa in fase.Tarefas) { observableCollection.Add(new Tuple(string.Format(" TAREFA {0}$", fase.Tarefas.IndexOf(tarefa) + 1), "", "")); observableCollection.Add(new Tuple(" TÍTULO DA TAREFA", (string.IsNullOrWhiteSpace(tarefa.Titulo) ? "" : tarefa.Titulo), "")); DateTime agendamento = tarefa.Agendamento; DateTime dateTime = tarefa.Agendamento; observableCollection.Add(new Tuple(" AGENDAMENTO DA TAREFA", dateTime.ToShortDateString(), "")); DateTime agendamento1 = tarefa.Agendamento; dateTime = tarefa.Agendamento; observableCollection.Add(new Tuple(" HORA DA TAREFA", dateTime.ToShortTimeString(), "")); observableCollection.Add(new Tuple(" ANOTAÇÕES DA TAREFA", (string.IsNullOrWhiteSpace(tarefa.Anotacoes) ? "" : tarefa.Anotacoes), "")); observableCollection.Add(new Tuple(" STATUS DA TAREFA", tarefa.Status.GetDescription(), "")); } } tupleLists.Add(new TupleList() { Tuples = observableCollection }); } return tupleLists; } public List> Validate() { List> keyValuePairs = ValidationHelper.AddValue(); if (string.IsNullOrWhiteSpace(this.Titulo)) { keyValuePairs.AddValue("Titulo", Messages.Obrigatorio, true); } if (this.Fases == null || this.Fases.Count == 0) { keyValuePairs.AddValue("Fases", Messages.Obrigatorio, true); } return keyValuePairs; } } }