Esempio n. 1
0
        private bool ValidateFields()
        {
            bool result = true;

            if (certificateCode.Equals("5"))
            {
                if (CountrySelected == null)
                {
                    ErrorCountry = true;
                    result       = false;
                }
                if (Cities.Count(x => x.IsSelected == true) < 1)
                {
                    ErrorCity = true;
                    result    = false;
                }
            }
            if (CertificateCode.Equals("3"))
            {
                if (string.IsNullOrWhiteSpace(DateSelected))
                {
                    result    = false;
                    ErrorDate = true;
                }
            }

            return(result);
        }
Esempio n. 2
0
        private async void OpenPdf(bool email = false)
        {
            try
            {
                var selectedCities = new List <CertificateCities>();
                CleanError();

                if (ValidateFields())
                {
                    if (CitiesSelected.Count > 0)
                    {
                        foreach (var city in CitiesSelected)
                        {
                            selectedCities.Add(
                                new CertificateCities
                            {
                                Code        = city.Code,
                                Description = city.Description,
                                Name        = city.Name
                            });
                        }
                    }
                    dialogService.ShowProgress();
                    var request = new RequestDownloadCertificate
                    {
                        NameCountry       = CountrySelected != null ? CountrySelected.Name : string.Empty,
                        CertificateCode   = int.Parse(CertificateCode),
                        CodeCity          = selectedCities,
                        Country           = CountrySelected != null ? CountrySelected.Code : string.Empty,
                        Document          = Document,
                        CertifiedYear     = DateSelected,
                        DateEnd           = CertificateCode.Equals("5") ? EndDateSelected.ToString("yyyy-MM-dd") : string.Empty,
                        DateStart         = CertificateCode.Equals("5") ? StartDateSelected.ToString("yyyy-MM-dd") : string.Empty,
                        DocumentType      = DocumentType,
                        FileName          = FileName,
                        FullNameCertified = $"{loginViewModel.User.NameOne} {loginViewModel.User.NameTwo} {loginViewModel.User.LastNameOne} {loginViewModel.User.LastNameTwo}",
                        GroupCode         = GroupCode,
                        Name            = Name,
                        Mail            = email ? loginViewModel.User.UserName : string.Empty,
                        RequestGroup    = Name.Equals("Grupo Familiar"),
                        TypeCertificate = TypeCertificate,
                        Controller      = "Affiliate",
                        Action          = email ? "GetSendCertAffiliatedPayments" : "GetDownloadCertAffiliatedPayments"
                    };
                    if (email)
                    {
                        var response = await apiService.SendCertAffiliatedPayments(request);

                        dialogService.HideProgress();
                        if (response.Success)
                        {
                            await dialogService.ShowMessage("Proceso exitoso", $"Hemos enviado al correo electrónico {loginViewModel.User.UserName} el certificado seleccionado");
                        }
                        else
                        {
                            await dialogService.ShowMessage(response.Title, response.Message);
                        }
                    }
                    else
                    {
                        var response = await apiService.GetDownloadCertAffiliatedPayments(request);

                        dialogService.HideProgress();
                        if (response.Success)
                        {
                            IPdfPageViewModel pdfPage = ServiceLocator.Current.GetInstance <IPdfPageViewModel>();
                            var bytes = Convert.FromBase64String(response.Download.BitCertificate);
                            pdfPage.OpenPdf("", response.Download.NameCertificate, bytes, true, CertificateName);
                        }
                        else
                        {
                            await dialogService.ShowMessage(response.Title, response.Message);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ServiceLocator.Current.GetInstance <IExceptionService>().RegisterException(e);
            }
        }
Esempio n. 3
0
 public override int GetHashCode()
 {
     return(CertificateCode.GetHashCode() ^ Sum.GetHashCode() ^ Used.GetHashCode() * 123 ^ Paid.GetHashCode() * 321 ^ Enable.GetHashCode() * 323);
 }