예제 #1
0
 public Torneo GetTorneo(int id)
 {
     using (var proxy = new WSTorneo.TorneoServiceClient())
     {
         return proxy.ObtenerTorneoPorID(id);
     }
 }
        public int CrearContendor(Contendor contendor)
        {
            if (string.IsNullOrEmpty(contendor.Nombre) ||
                string.IsNullOrEmpty(contendor.Texto) ||
                string.IsNullOrEmpty(contendor.RutaImagen))
                throw new FaultException("Información básica del contendor incompleta");

            if (!contendor.RutaImagen.ToLower().EndsWith(".jpg") &&
                !contendor.RutaImagen.ToLower().EndsWith(".gif") &&
                !contendor.RutaImagen.ToLower().EndsWith(".png") &&
                !contendor.RutaImagen.ToLower().EndsWith(".bmp") &&
                !contendor.RutaImagen.ToLower().EndsWith(".jpeg"))
                throw new FaultException("Formato de archivo inválido");

            using (var proxy = new WSTorneo.TorneoServiceClient())
            {
                var contendores = contendorDA.ListarContendores(contendor.IDTorneo);
                var torneo = proxy.ObtenerTorneoPorID(contendor.IDTorneo);

                if (contendores.Count == torneo.NumeroContendores)
                {
                    throw new FaultException("Límite de contendores ha exedido");
                }

                return contendorDA.CrearContendor(contendor);
            }
        }
예제 #3
0
        public void CrearTorneo()
        {
            using (var proxyUsuario = new WSUsuario.UsuarioServiceClient())
            {
                var usuario = proxyUsuario.ObtenerUsuarioPorCorreo("*****@*****.**");

                using (var proxy = new WSTorneo.TorneoServiceClient())
                {
                    var idTorneo = proxy.CrearTorneo(usuario.ID, new Torneo
                    {
                        Nombre = "Mejor alumno del curso DSD",
                        Enlace = "http://localhost/WhoIsBetter/index.html#/Torneos/mejoralumnodelcursodsd",
                        IDEstado = 1,
                        FechaInicio = DateTime.Today,
                        FechaFin = DateTime.Today.AddDays(2),
                        NumeroContendores = 16,
                        NumeroParticipantes = 3
                    });

                    var torneo = proxy.ObtenerTorneoPorID(idTorneo);

                    Assert.AreEqual("Mejor alumno del curso DSD", torneo.Nombre);
                    Assert.AreEqual(16, torneo.NumeroContendores);
                    Assert.AreEqual(3, torneo.NumeroParticipantes);
                }
            }
        }
        public int InscribirParticipante(int idTorneo, Participante participante)
        {
            if (string.IsNullOrEmpty(participante.Correo) || string.IsNullOrEmpty(participante.Nombre))
                throw new FaultException("Información básica del participante incompleta");

            if (!Validador.EsCorreo(participante.Correo))
                throw new FaultException("Formato de correo incorrecto");

            using (var proxy = new WSTorneo.TorneoServiceClient())
            {
                var torneo = proxy.ObtenerTorneoPorID(idTorneo);

                if (torneo.IDEstado == 3 || torneo.IDEstado == 4)
                    throw new FaultException("Torneo ya no se encuentra vigente");

                var entity = participanteDA.ObtenerParticipante(idTorneo, participante.Correo);

                if (entity != null) return entity.ID;

                torneo.NumeroRealParticipantes++;

                if (torneo.NumeroRealParticipantes >= torneo.NumeroParticipantes)
                    throw new FaultException("Torneo llegó al límite de participantes");

                var idParticipante = participanteDA.InscribirParticipante(idTorneo, participante);

                return idParticipante;
            }
        }
예제 #5
0
        public void ObtenerTorneo()
        {
            using (var proxy = new WSTorneo.TorneoServiceClient())
            {
                var torneo = proxy.ObtenerTorneoPorEnlace("http://localhost/WhoIsBetter/index.html#/Torneos/mejoralumnodelcursodsd");

                torneo = proxy.ObtenerTorneoPorID(torneo.ID);

                Assert.AreEqual("Mejor alumno del curso DSD", torneo.Nombre);
                Assert.AreEqual(16, torneo.NumeroContendores);
                Assert.AreEqual(3, torneo.NumeroParticipantes);
            }
        }
예제 #6
0
        public void EliminarTorneo()
        {
            using (var proxy = new WSTorneo.TorneoServiceClient())
            {
                var torneo = proxy.ObtenerTorneoPorEnlace("http://localhost/WhoIsBetter/index.html#/Torneos/mejoralumnodelcursodsd");

                proxy.EliminarTorneo(torneo.ID);

                torneo = proxy.ObtenerTorneoPorID(torneo.ID);

                Assert.AreEqual(null, torneo);
            }
        }
예제 #7
0
        public void ActualizarTorneo()
        {
            using (var proxy = new WSTorneo.TorneoServiceClient())
            {
                var torneo = proxy.ObtenerTorneoPorEnlace("http://localhost/WhoIsBetter/index.html#/Torneos/mejoralumnodelcursodsd");
                torneo.NumeroParticipantes = 5;

                proxy.ActualizarTorneo(torneo);

                torneo = proxy.ObtenerTorneoPorID(torneo.ID);

                Assert.AreEqual(5, torneo.NumeroParticipantes);
            }
        }