コード例 #1
0
        public async Task OnGet(Guid id)
        {
            var   t = Task.Run(() => _appServiceTipo.List());
            await t;

            var   s = Task.Run(() => _appServiceSetor.List());
            await s;

            var p = Task.Run(() => _appServiceParceiro.List());

            if (t.Result != null)
            {
                TipoEventos = new SelectList(t.Result, nameof(Tipo.Nome), nameof(Tipo.Nome), null);
            }

            if (s.Result != null)
            {
                Setores = new SelectList(s.Result, nameof(Setor.Nome), nameof(Setor.Nome), null);
            }

            if (p.Result != null)
            {
                Parceiros = new SelectList(p.Result, nameof(Parceiro.Nome), nameof(Parceiro.Nome), null);
            }

            var   evento = Task.Run(() => _appServiceEvento.GetById(id));
            await evento;

            Input = _mapper.Map <InputModelEvento>(evento.Result);
        }
コード例 #2
0
        public async Task <IActionResult> OnPostSaveAsync()
        {
            var ja_inscricao = false;

            if (Input.Evento == null || Input.Participante == null)
            {
                StatusMessage = "Erro: Verifique se os campos foram preenchidos corretamente!";
                return(Page());
            }

            var t = Task.Run(() =>
            {
                //var user = _userManager.Users.FirstOrDefault(m => m.UserName == User.Identity.Name).Id;

                var inscricao = new Inscricao()
                {
                    AplicationUser_Id = User.Identity.Name,
                    Data_Inscricao    = DateTime.Now,
                    Presente          = false
                };

                var numero = _appServiceInscricao.LastCodigo();

                if (numero < 1)
                {
                    inscricao.Numero = 100001;
                }
                else
                {
                    inscricao.Numero = numero + 1;
                }

                var pessoa = _appServicePessoa.GetById(Input.Participante.Id);

                if (pessoa != null)
                {
                    inscricao.Participante = pessoa;
                }

                if (Input.Empresa != null)
                {
                    var empresa = _appServiceEmpresa.GetById(Input.Empresa.Id);

                    if (empresa != null)
                    {
                        inscricao.Empresa = empresa;
                    }
                }

                var evento = _appServiceEvento.GetById(Input.Evento.Id);

                if (evento != null)
                {
                    inscricao.Evento = evento;
                }

                ja_inscricao = _appServiceInscricao.JaInscrito(inscricao.Participante.CPF, inscricao.Evento.Codigo);

                if (ja_inscricao)
                {
                    StatusMessage = "Erro: Pessoa já consta na lista de participantes!";
                }
                else
                {
                    _appServiceInscricao.Add(inscricao);
                }
            });

            await t;

            if (ja_inscricao)
            {
                return(Page());
            }
            else
            {
                return(RedirectToPage("./Index"));
            }
        }