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/CoberturaViewModel.cs | 285 +++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/CoberturaViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/CoberturaViewModel.cs') diff --git a/Codemerx/Gestor.Application/ViewModels/CoberturaViewModel.cs b/Codemerx/Gestor.Application/ViewModels/CoberturaViewModel.cs new file mode 100644 index 0000000..fb35f4d --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/CoberturaViewModel.cs @@ -0,0 +1,285 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +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 CoberturaViewModel : BaseSegurosViewModel + { + private readonly ItemServico _itemServico; + + private Cobertura _selectedCobertura; + + private List _coberturasPadrao; + + private ObservableCollection _coberturas; + + private readonly IComparer _comparerCobertura; + + public ObservableCollection Coberturas + { + get + { + return this._coberturas; + } + set + { + this._coberturas = value; + base.OnPropertyChanged("Coberturas"); + } + } + + public List CoberturasPadrao + { + get + { + return this._coberturasPadrao; + } + set + { + this._coberturasPadrao = value; + base.OnPropertyChanged("CoberturasPadrao"); + } + } + + public Gestor.Model.Domain.Seguros.Item Item + { + get; + set; + } + + public Gestor.Model.Domain.Seguros.Ramo Ramo + { + get; + set; + } + + public Cobertura SelectedCobertura + { + get + { + return this._selectedCobertura; + } + set + { + this._selectedCobertura = value; + base.OnPropertyChanged("SelectedCobertura"); + } + } + + public CoberturaViewModel(Gestor.Model.Domain.Seguros.Ramo ramo = null, Gestor.Model.Domain.Seguros.Item item = null) + { + // + // Current member / type: System.Void Gestor.Application.ViewModels.CoberturaViewModel::.ctor(Gestor.Model.Domain.Seguros.Ramo,Gestor.Model.Domain.Seguros.Item) + // File path: C:\AggerSeguros\Gestor.Application.exe + // + // Product version: 0.0.0.0 + // Exception in: System.Void .ctor(Gestor.Model.Domain.Seguros.Ramo,Gestor.Model.Domain.Seguros.Item) + // + // Object reference not set to an instance of an object. + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515 + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459 + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378 + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331 + // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 + // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61 + // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133 + // + // mailto: JustDecompilePublicFeedback@telerik.com + + } + + public void AdicionaCobertura() + { + Cobertura cobertura = new Cobertura(); + cobertura.set_Item(this.Item); + Cobertura cobertura1 = cobertura; + ValidationHelper.AddSorted(this.Coberturas, cobertura1, this._comparerCobertura); + this.SelectedCobertura = cobertura1; + } + + internal async Task> BuscarCobertura(string value) + { + Func func2 = null; + List coberturaPadraos = await Task.Run>(() => { + List coberturasPadrao = this.CoberturasPadrao; + if (coberturasPadrao == null) + { + return null; + } + Func u003cu003e9_1 = func2; + if (u003cu003e9_1 == null) + { + Func func = (CoberturaPadrao x) => ValidationHelper.RemoveDiacritics(x.get_Descricao().ToUpper().Trim()).Contains(value.ToUpper()); + Func func1 = func; + func2 = func; + u003cu003e9_1 = func1; + } + return coberturasPadrao.Where(u003cu003e9_1).ToList(); + }); + return coberturaPadraos; + } + + public async Task CancelarAlteracao() + { + if (this.Item != null) + { + this.Coberturas = await this._itemServico.BuscarCoberturasPorItemAsync(this.Item.get_Id()); + } + } + + public ObservableCollection CarregaCoberturaPadrao() + { + List list; + List coberturasPadrao = this.CoberturasPadrao; + if (coberturasPadrao != null) + { + list = ( + from x in coberturasPadrao + where x.get_Padrao() + select x).Select((CoberturaPadrao x) => { + Cobertura cobertura = new Cobertura(); + cobertura.set_CoberturaPadrao(x); + cobertura.set_Observacao(x.get_Descricao()); + return cobertura; + }).ToList(); + } + else + { + list = null; + } + ObservableCollection observableCollection = new ObservableCollection(list); + ObservableCollection observableCollection1 = observableCollection; + this.Coberturas = observableCollection; + return observableCollection1; + } + + public void CarregaPadrao() + { + List list; + List coberturasPadrao = this.CoberturasPadrao; + if (coberturasPadrao != null) + { + list = ( + from x in coberturasPadrao + where x.get_Padrao() + select x).Select((CoberturaPadrao x) => { + Cobertura cobertura = new Cobertura(); + cobertura.set_CoberturaPadrao(x); + cobertura.set_Observacao(x.get_Descricao()); + return cobertura; + }).ToList(); + } + else + { + list = null; + } + List coberturas = list; + if (coberturas == null) + { + return; + } + this.Coberturas = new ObservableCollection(coberturas); + } + + public async void ExcluirCobertura(Cobertura cobertura) + { + if (cobertura != null) + { + string[] newLine = new string[] { "DESEJA REALMENTE EXCLUIR A COBERTURA", Environment.NewLine, "\"", cobertura.get_Observacao(), "\"?" }; + if (await base.ShowMessage(string.Concat(newLine), "SIM", "NÃO", false)) + { + this.Coberturas.Remove(cobertura); + } + } + } + + public async Task> LimpaCoberturas() + { + bool flag; + IList list; + if (this.Coberturas == null) + { + flag = false; + } + else + { + ObservableCollection coberturas = this.Coberturas; + flag = coberturas.Any((Cobertura x) => { + if (!(x.get_Franquia() == decimal.Zero) || !(x.get_Lmi() == decimal.Zero)) + { + return false; + } + return x.get_Premio() == decimal.Zero; + }); + } + bool flag1 = flag; + if (flag1) + { + flag1 = await base.ShowMessage("DESEJA LIMPAR AS COBERTURAS SEM VALOR DE FRANQUIA, LMI E PRÊMIO?", "SIM", "NÃO", false); + } + if (flag1) + { + ObservableCollection observableCollection = this.Coberturas; + if (observableCollection != null) + { + list = observableCollection.Where((Cobertura x) => { + if (string.IsNullOrEmpty(x.get_Observacao())) + { + return false; + } + if (x.get_Franquia() != decimal.Zero || x.get_Lmi() != decimal.Zero) + { + return true; + } + return x.get_Premio() != decimal.Zero; + }).ToList(); + } + else + { + list = null; + } + } + else + { + ObservableCollection coberturas1 = this.Coberturas; + if (coberturas1 != null) + { + list = coberturas1.ToList(); + } + else + { + list = null; + } + } + return list; + } + + public async Task SelectionaCoberturas() + { + if (this.Ramo != null) + { + this.CoberturasPadrao = ( + from x in Recursos.Coberturas + where x.get_IdRamo() == this.Ramo.get_Id() + select x).ToList(); + if (this.Item != null) + { + this.Coberturas = await this._itemServico.BuscarCoberturasPorItemAsync(this.Item.get_Id()); + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3