예제 #1
0
        private void btnregistrar_Click(object sender, EventArgs e)
        {
            //controlar la duplicidad de Dni
            Boolean encuentra = false;

            foreach (Postulantes reg in listaPostulante)
            {
                if (reg.dni == txtdni.Text.ToUpper())
                {
                    MessageBox.Show("Ya se encuentra ese DNI registrado...", "AVISO");
                    encuentra = true;
                    break;
                }
            }
            if (encuentra == false)
            {
                obj          = new Postulantes();
                obj.codigo   = txtcodigo.Text;
                obj.dni      = txtdni.Text.ToUpper();
                obj.nombre   = txtnombre.Text;
                obj.apellido = txtapellido.Text;
                obj.grado    = cbogrado.Text;
                obj.correo   = txtcorreo.Text;
                listaPostulante.Add(obj);
                listado();
                limpiar();
            }
        }
예제 #2
0
        public IActionResult addPostulante(int idViaje, int idPostulante)
        {
            try
            {
                var user        = this.userRepository.GetAllUserById(idPostulante);
                var viaje       = this.genericRepo.GetAllById(idViaje);
                var postulantes = new Postulantes()
                {
                    User    = user,
                    UserId  = idPostulante,
                    Viaje   = viaje,
                    ViajeId = idViaje
                };

                // var pst = this.postulantesRepository.Create(postulantes);
                var pst = new Postulantes()
                {
                    User    = user,
                    UserId  = user.Id,
                    Viaje   = viaje,
                    ViajeId = viaje.Id
                };
                viaje.Postulantes.Add(pst);
                this.genericRepo.Update(viaje.Id, viaje);
                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest("Hubo un error en AgregarPostulante"));
            }
        }