From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../ViewModels/Generic/BaseTarefaViewModel.cs | 233 --------------------- 1 file changed, 233 deletions(-) delete mode 100644 Gestor.Application/ViewModels/Generic/BaseTarefaViewModel.cs (limited to 'Gestor.Application/ViewModels/Generic/BaseTarefaViewModel.cs') diff --git a/Gestor.Application/ViewModels/Generic/BaseTarefaViewModel.cs b/Gestor.Application/ViewModels/Generic/BaseTarefaViewModel.cs deleted file mode 100644 index ad8c5a5..0000000 --- a/Gestor.Application/ViewModels/Generic/BaseTarefaViewModel.cs +++ /dev/null @@ -1,233 +0,0 @@ -using Gestor.Application.Helpers; -using Gestor.Application.Servicos; -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.Generic -{ - public abstract class BaseTarefaViewModel : BaseSegurosViewModel - { - private ObservableCollection _responsaveis = new ObservableCollection(); - - private bool _hasResponsaveis; - - public abstract bool EnableAlterarTarefa - { - get; - set; - } - - public bool HasResponsaveis - { - get - { - return this._hasResponsaveis; - } - set - { - this._hasResponsaveis = value; - base.OnPropertyChanged("HasResponsaveis"); - } - } - - public ObservableCollection Responsaveis - { - get - { - return this._responsaveis; - } - set - { - this._responsaveis = value; - this.HasResponsaveis = (value != null ? value.Count > 0 : false); - base.OnPropertyChanged("Responsaveis"); - } - } - - public abstract Tarefa SelectedTarefa - { - get; - set; - } - - public TarefaServico Servico - { - get; - set; - } - - protected BaseTarefaViewModel() - { - } - - internal async Task BuscaPermisaoUsuario() - { - return await (new PermissaoUsuarioServico()).VerificarPermissao(Recursos.Usuario, 38); - } - - public void ListaUsuariosResponsaveis() - { - bool usuario; - Tarefa selectedTarefa = this.SelectedTarefa; - if (selectedTarefa != null) - { - usuario = selectedTarefa.get_Usuario(); - } - else - { - usuario = false; - } - if (!usuario) - { - return; - } - if (!this.Responsaveis.Any((ResponsavelTarefa r) => r.get_Usuario().get_Id() == this.SelectedTarefa.get_Usuario().get_Id())) - { - ObservableCollection responsaveis = this.Responsaveis; - ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa(); - responsavelTarefa.set_IdTarefa(this.SelectedTarefa.get_Id()); - responsavelTarefa.set_Usuario(this.SelectedTarefa.get_Usuario()); - responsaveis.Insert(0, responsavelTarefa); - } - } - - public async Task ValidaPermissaoParaEditarTarefa() - { - bool flag; - bool flag1; - bool flag2; - bool id; - bool flag3; - bool flag4 = false; - if (this.SelectedTarefa != null) - { - PermissaoUsuario permissaoUsuario = await this.BuscaPermisaoUsuario(); - if (Recursos.Usuario.get_Administrador()) - { - flag4 = true; - } - else if (permissaoUsuario == null && !this.SelectedTarefa.get_Restrito().GetValueOrDefault()) - { - flag4 = true; - } - else if (permissaoUsuario != null && !permissaoUsuario.get_Alterar()) - { - flag4 = false; - } - else if (!this.SelectedTarefa.get_Restrito().GetValueOrDefault()) - { - flag4 = true; - } - else - { - if (this.SelectedTarefa.get_UsuarioCadastro().get_Id() != Recursos.Usuario.get_Id()) - { - List responsaveis = this.SelectedTarefa.get_Responsaveis(); - if (responsaveis != null) - { - flag3 = responsaveis.Any((ResponsavelTarefa x) => x.get_Usuario().get_Id() == Recursos.Usuario.get_Id()); - } - else - { - flag3 = false; - } - if (flag3) - { - goto Label1; - } - id = this.SelectedTarefa.get_Usuario().get_Id() == Recursos.Usuario.get_Id(); - goto Label0; - } - Label1: - id = true; - Label0: - flag4 = id; - } - bool flag5 = flag4; - bool flag6 = flag5; - this.EnableAlterarTarefa = flag5; - bool flag7 = flag6; - flag2 = flag7; - base.EnableExcluir = flag7; - bool flag8 = flag2; - flag1 = flag8; - base.EnableAlterar = flag8; - flag = flag1; - } - else - { - bool flag9 = flag4; - flag2 = flag9; - this.EnableAlterarTarefa = flag9; - bool flag10 = flag2; - flag1 = flag10; - base.EnableExcluir = flag10; - base.EnableAlterar = flag1; - flag = flag4; - } - return flag; - } - - public async Task ValidaPermissaoParaExcluirTarefa(Tarefa tarefa = null) - { - bool id; - bool flag; - if (tarefa != null) - { - this.SelectedTarefa = tarefa; - } - PermissaoUsuario permissaoUsuario = await this.BuscaPermisaoUsuario(); - bool flag1 = false; - if (Recursos.Usuario.get_Administrador()) - { - flag1 = true; - } - else if (permissaoUsuario == null && !this.SelectedTarefa.get_Restrito().GetValueOrDefault()) - { - flag1 = true; - } - else if (permissaoUsuario != null && !permissaoUsuario.get_Excluir()) - { - flag1 = false; - } - else if (!this.SelectedTarefa.get_Restrito().GetValueOrDefault()) - { - flag1 = true; - } - else - { - if (this.SelectedTarefa.get_UsuarioCadastro().get_Id() != Recursos.Usuario.get_Id()) - { - List responsaveis = this.SelectedTarefa.get_Responsaveis(); - if (responsaveis != null) - { - flag = responsaveis.Any((ResponsavelTarefa x) => x.get_Usuario().get_Id() == Recursos.Usuario.get_Id()); - } - else - { - flag = false; - } - if (flag) - { - goto Label1; - } - id = this.SelectedTarefa.get_Usuario().get_Id() == Recursos.Usuario.get_Id(); - goto Label0; - } - Label1: - id = true; - Label0: - flag1 = id; - } - return flag1; - } - } -} \ No newline at end of file -- cgit v1.2.3