summaryrefslogtreecommitdiff
path: root/Gestor.Model/Gestor.Model.Domain.Ferramentas/Trilha.cs
blob: f627dc510dd7d71bad8766e9a3e81490f5481d0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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;

namespace Gestor.Model.Domain.Ferramentas;

public class Trilha : DomainBase, IDomain
{
	public string Titulo { get; set; }

	public string Descricao { get; set; }

	public List<Fase> Fases { get; set; }

	public bool Ativo { get; set; }

	public TipoTrilha Tipo { get; set; }

	[JsonIgnore]
	public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate;

	public List<KeyValuePair<string, string>> Validate()
	{
		List<KeyValuePair<string, string>> list = ValidationHelper.AddValue();
		if (string.IsNullOrWhiteSpace(Titulo))
		{
			list.AddValue("Titulo", Messages.Obrigatorio);
		}
		if (Fases == null || Fases.Count == 0)
		{
			list.AddValue("Fases", Messages.Obrigatorio);
		}
		return list;
	}

	public List<TupleList> Log()
	{
		List<TupleList> list = new List<TupleList>();
		list.Add(new TupleList
		{
			Tuples = new ObservableCollection<Tuple<string, string, string>>
			{
				new Tuple<string, string, string>("TÍTULO DA TRILHA", string.IsNullOrWhiteSpace(Titulo) ? "" : Titulo, ""),
				new Tuple<string, string, string>("DESCRIÇÃO DA TRILHA", string.IsNullOrWhiteSpace(Descricao) ? "" : Descricao, ""),
				new Tuple<string, string, string>("ATIVO", Ativo ? "SIM" : "NÃO", "")
			}
		});
		ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>>
		{
			new Tuple<string, string, string>("FASES$", "", "")
		};
		if (Fases != null)
		{
			foreach (Fase fase in Fases)
			{
				observableCollection.Add(new Tuple<string, string, string>($"   FASE {Fases.IndexOf(fase) + 1}$", "", ""));
				observableCollection.Add(new Tuple<string, string, string>("      TÍTULO DA FASE", string.IsNullOrWhiteSpace(fase.Titulo) ? "" : fase.Titulo, ""));
				observableCollection.Add(new Tuple<string, string, string>("      DESCRIÇÃO DA FASE", string.IsNullOrWhiteSpace(fase.Descricao) ? "" : fase.Descricao, ""));
				foreach (Tarefa tarefa in fase.Tarefas)
				{
					observableCollection.Add(new Tuple<string, string, string>($"   TAREFA {fase.Tarefas.IndexOf(tarefa) + 1}$", "", ""));
					observableCollection.Add(new Tuple<string, string, string>("      TÍTULO DA TAREFA", string.IsNullOrWhiteSpace(tarefa.Titulo) ? "" : tarefa.Titulo, ""));
					_ = tarefa.Agendamento;
					observableCollection.Add(new Tuple<string, string, string>("      AGENDAMENTO DA TAREFA", tarefa.Agendamento.ToShortDateString(), ""));
					_ = tarefa.Agendamento;
					observableCollection.Add(new Tuple<string, string, string>("      HORA DA TAREFA", tarefa.Agendamento.ToShortTimeString(), ""));
					observableCollection.Add(new Tuple<string, string, string>("      ANOTAÇÕES DA TAREFA", string.IsNullOrWhiteSpace(tarefa.Anotacoes) ? "" : tarefa.Anotacoes, ""));
					observableCollection.Add(new Tuple<string, string, string>("      STATUS DA TAREFA", tarefa.Status.GetDescription(), ""));
				}
			}
			list.Add(new TupleList
			{
				Tuples = observableCollection
			});
		}
		return list;
	}
}