diff options
Diffstat (limited to 'Gestor.Application/ViewModels/TrilhaViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/TrilhaViewModel.cs | 284 |
1 files changed, 0 insertions, 284 deletions
diff --git a/Gestor.Application/ViewModels/TrilhaViewModel.cs b/Gestor.Application/ViewModels/TrilhaViewModel.cs deleted file mode 100644 index a818704..0000000 --- a/Gestor.Application/ViewModels/TrilhaViewModel.cs +++ /dev/null @@ -1,284 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Helpers;
-using Gestor.Application.Servicos;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Ferramentas;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace Gestor.Application.ViewModels
-{
- public class TrilhaViewModel : BaseSegurosViewModel
- {
- private ObservableCollection<Trilha> _trilhas = new ObservableCollection<Trilha>();
-
- private ObservableCollection<Fase> _fases = new ObservableCollection<Fase>();
-
- private Trilha _selectedTrilha = new Trilha();
-
- private Tarefa _selectedTarefa;
-
- private ObservableCollection<Usuario> _usuarios;
-
- private Usuario _selectedUsuario = new Usuario();
-
- public ObservableCollection<Fase> Fases
- {
- get
- {
- return this._fases;
- }
- set
- {
- this._fases = value;
- base.OnPropertyChanged("Fases");
- }
- }
-
- public Tarefa SelectedTarefa
- {
- get
- {
- return this._selectedTarefa;
- }
- set
- {
- this._selectedTarefa = value;
- base.OnPropertyChanged("SelectedTarefa");
- }
- }
-
- public Trilha SelectedTrilha
- {
- get
- {
- return this._selectedTrilha;
- }
- set
- {
- this._selectedTrilha = value;
- base.OnPropertyChanged("SelectedTrilha");
- }
- }
-
- public Usuario SelectedUsuario
- {
- get
- {
- return this._selectedUsuario;
- }
- set
- {
- this._selectedUsuario = value;
- base.OnPropertyChanged("SelectedUsuario");
- }
- }
-
- private TarefaServico Servico
- {
- get;
- }
-
- public ObservableCollection<Trilha> Trilhas
- {
- get
- {
- return this._trilhas;
- }
- set
- {
- this._trilhas = value;
- base.OnPropertyChanged("Trilhas");
- }
- }
-
- public ObservableCollection<Usuario> Usuarios
- {
- get
- {
- return this._usuarios;
- }
- set
- {
- this._usuarios = value;
- base.OnPropertyChanged("Usuarios");
- }
- }
-
- public TrilhaViewModel()
- {
- this.Servico = new TarefaServico();
- List<Usuario> usuarios = new List<Usuario>();
- Usuario usuario = new Usuario();
- usuario.set_Id((long)0);
- usuario.set_Nome("TODOS OS USUÁRIOS");
- usuarios.Add(usuario);
- List<Usuario> usuarios1 = usuarios;
- usuarios1.AddRange(Recursos.Usuarios.Where<Usuario>((Usuario x) => {
- if (Recursos.Usuario.get_IdEmpresa() != (long)1 && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa())
- {
- return false;
- }
- return !x.get_Excluido();
- }).OrderBy<Usuario, string>((Usuario x) => x.get_Nome()).ToList<Usuario>());
- this.Usuarios = new ObservableCollection<Usuario>(usuarios1);
- this.SelectedUsuario = this.Usuarios.First<Usuario>();
- Gestor.Application.Actions.Actions.AtualizaTrilhas = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.AtualizaTrilhas, new Action(this.AtualizarTrilhas));
- this.CarregaTrilhas();
- }
-
- public void AtualizarTrilhas()
- {
- this.CarregaTrilhas();
- }
-
- public async Task Cancelar()
- {
- await this.CarregarTrilha(this.SelectedTrilha);
- base.Alterar(false);
- }
-
- public async Task CarregarTrilha(Trilha trilha)
- {
- if (trilha != null && trilha.get_Id() != 0)
- {
- this.SelectedTrilha = trilha;
- List<Tarefa> tarefas = await this.Servico.BuscarTarefas(trilha.get_Id());
- List<Tarefa> tarefas1 = tarefas;
- List<Fase> fases = await this.Servico.BuscarFases(trilha.get_Id());
- this.Fases = new ObservableCollection<Fase>();
- fases.ForEach((Fase x) => {
- x.set_Tarefas(tarefas1.Where<Tarefa>((Tarefa t) => {
- if (this.SelectedUsuario != null && this.SelectedUsuario.get_Id() != 0 && this.SelectedUsuario.get_Id() != t.get_Usuario().get_Id() || t.get_Fase().get_Id() != x.get_Id())
- {
- return false;
- }
- return t.get_Status() != 2;
- }).ToList<Tarefa>());
- this.Fases.Add(x);
- });
- }
- }
-
- public async Task CarregarTrilhas(Trilha trilha = null)
- {
- Trilha trilha1;
- List<Trilha> trilhas = await this.Servico.BuscarTrilhas();
- this.Trilhas = new ObservableCollection<Trilha>(trilhas);
- TrilhaViewModel trilhaViewModel = this;
- trilha1 = (trilha != null ? this.Trilhas.FirstOrDefault<Trilha>((Trilha x) => x.get_Id() == trilha.get_Id()) : trilhas.FirstOrDefault<Trilha>());
- await trilhaViewModel.CarregarTrilha(trilha1);
- }
-
- public async void CarregaTrilhas()
- {
- await this.CarregarTrilhas(null);
- }
-
- public void Excluir(Fase origem, Tarefa data)
- {
- Tarefa tarefa = this.Fases.First<Fase>((Fase x) => x.get_Id() == origem.get_Id()).get_Tarefas().First<Tarefa>((Tarefa x) => x.get_Id() == data.get_Id());
- this.Fases.First<Fase>((Fase x) => x.get_Id() == origem.get_Id()).get_Tarefas().Remove(tarefa);
- }
-
- public async Task Excluir(Tarefa tarefa)
- {
- if (tarefa.get_Id() != 0)
- {
- string[] titulo = new string[] { "DESEJA REALMENTE EXCLUIR A TAREFA ", tarefa.get_Titulo(), "?", Environment.NewLine, "ESSE PROCEDIMENTO É IRREVERSÍVEL" };
- if (await base.ShowMessage(string.Concat(titulo), "SIM", "NÃO", false))
- {
- if (await this.Servico.Excluir(tarefa.get_Id()))
- {
- await this.CarregarTrilha(this.SelectedTrilha);
- base.Alterar(false);
- }
- else
- {
- base.Alterar(false);
- }
- }
- }
- }
-
- public void Inserir(Fase origem, Tarefa data, int index, bool aberto = false)
- {
- data.set_Aberto(aberto);
- data.set_Fase(origem);
- this.Fases.First<Fase>((Fase x) => x.get_Id() == origem.get_Id()).get_Tarefas().Insert((index == -1 ? 0 : index), data);
- this.TrocarFase(data);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar(Tarefa destino)
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- Tarefa tarefa = destino;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- tarefa.set_AgendamentoRetroativo(configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 45));
- List<KeyValuePair<string, string>> keyValuePairs1 = destino.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- await this.Servico.Salvar(destino);
- if (this.Servico.Sucesso)
- {
- await this.CarregarTrilha(this.SelectedTrilha);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- return keyValuePairs;
- }
-
- public async Task Salvar(Trilha destino)
- {
- TrilhaViewModel.u003cu003ec__DisplayClass37_0 variable;
- this.SelectedTrilha = null;
- this.Fases = null;
- List<Fase> fases = destino.get_Fases();
- Trilha trilha = await this.Servico.Salvar(destino);
- if (this.Servico.Sucesso)
- {
- if (fases != null)
- {
- fases.ForEach((Fase x) => x.set_Trilha(trilha));
- await this.Servico.Salvar(fases);
- if (!this.Servico.Sucesso)
- {
- variable = null;
- fases = null;
- return;
- }
- }
- await this.CarregarTrilhas(trilha);
- }
- variable = null;
- fases = null;
- }
-
- private async void TrocarFase(Tarefa tarefa)
- {
- await this.Servico.Salvar(tarefa);
- }
-
- public void Update()
- {
- this.Fases = new ObservableCollection<Fase>(this.Fases);
- }
- }
-}
\ No newline at end of file |