Example #1
0
        //Facade
        public void ModificarIndicadoresDieteticos(string comidasDia, string quienComida, string comeFuera, string AlimentosPref, string agua, string alergias, string notas, string recordatorio, int id)
        {
            var validac = new Validacion();

            if (validac.Longitud(comidasDia, 1, 50) && validac.Longitud(quienComida, 1, 20) && validac.Longitud(comeFuera, 1, 10) && validac.Longitud(AlimentosPref, 1, 100) && validac.Longitud(agua, 1, 50) && validac.Longitud(alergias, 1, 50))
            {
                try
                {
                    var modeloGenerales3 = new ModeloGenerales3();
                    modeloGenerales3.ModificarIndicadoresDieteticos(comidasDia, quienComida, comeFuera, AlimentosPref, agua, alergias, notas, recordatorio, id);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            else
            {
                error = "Los campos Comidas al Dia, Quien Prepara su Comida, Come Fuera, Alimentos Preferidos, Agua, y Alergias / Intolerancias a Comidas no deben estar vacios";
                return;
            }
        }
Example #2
0
        //Facade
        public void AgregarIndicadoresDieteticos(string comidasDia, string quienComida, string comeFuera, string AlimentosPref, string agua, string alergias, string notas, string recordatorio, int id)
        {
            var validac = new Validacion();

            if (validac.Longitud(comidasDia, 1, 50) && validac.Longitud(quienComida, 1, 20) && validac.Longitud(comeFuera, 1, 10) && validac.Longitud(AlimentosPref, 1, 100) && validac.Longitud(agua, 1, 50) && validac.Longitud(alergias, 1, 50))
            {
                try
                {
                    var modeloGenerales3 = new ModeloGenerales3();
                    modeloGenerales3.AgregarIndicadoresDieteticos(comidasDia, quienComida, comeFuera, AlimentosPref, agua, alergias, notas, recordatorio, id);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            else
            {
                error = "Los campos con * son necesarios";
                return;
            }
        }
Example #3
0
        public void ModificarDatosCita(string grasaVis, string CMB, string cirCad, string bodyAge, string cirCin, string musculoPorc, string grasaPorc, string IMC, string peso, DateTime fecha, int id, int idCita)
        {
            var validac = new Validacion();

            if (validac.Longitud(grasaVis, 1, 5) && validac.Longitud(CMB, 1, 5) && validac.Longitud(cirCad, 1, 5) && validac.Longitud(bodyAge, 1, 3) && validac.Longitud(cirCin, 1, 5) && validac.Longitud(musculoPorc, 1, 3) && validac.Longitud(grasaPorc, 1, 3) && validac.Longitud(IMC, 1, 5) && validac.Longitud(peso, 1, 5))
            {
                if (validac.MayorA(Convert.ToInt32(grasaVis), 0) && validac.MayorA(Convert.ToInt32(CMB), 0) && validac.MayorA(Convert.ToInt32(cirCad), 0) && validac.MayorA(Convert.ToInt32(bodyAge), 0) && validac.MayorA(Convert.ToInt32(cirCin), 0) && validac.MayorA(Convert.ToInt32(musculoPorc), 0) && validac.MayorA(Convert.ToInt32(grasaPorc), 0) && validac.MayorA(Convert.ToInt32(IMC), 0) && validac.MayorA(Convert.ToInt32(peso), 0))
                {
                    if (validac.FechaMayorIgualA(fecha, DateTime.Today))
                    {
                        try
                        {
                            var modelodc = new ModeloDatosxCita();
                            modelodc.ModificarDatosCita(grasaVis, CMB, cirCad, bodyAge, cirCin, musculoPorc, grasaPorc, IMC, peso, fecha, id, idCita);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }
                    }
                    else
                    {
                        error = "Fecha invalida";
                        return;
                    }
                }
                else
                {
                    error = "Las cantidades deben ser mayor a cero";
                    return;
                }
            }
            else
            {
                error = "Los campos con * no deben estar vacios";
                return;
            }
        }
Example #4
0
        public string AgregarUsuario(string usuario, string contrasena, int tipo)
        {
            var validac = new Validacion();

            if (validac.Longitud(usuario, 4, 15) == true)
            {
                if (validac.Longitud(contrasena, 8, 25) == true)
                {
                    if (validac.ContieneMinusculas(contrasena) == true && validac.ContieneMayusculas(contrasena) == true && validac.ContieneNumeros(contrasena) == true)
                    {
                        try
                        {
                            var mru = new ModeloRegistrarUsuario();
                            mensaje = mru.AgregarUsuario(usuario, contrasena, tipo);
                            return(mensaje);
                        }
                        catch (Exception ex)
                        {
                            return(ex.ToString());
                        }
                    }
                    else
                    {
                        return("La contraseña debe de tener caracteres en mayusculas, caracteres en minusculas y numeros");
                    }
                }
                else
                {
                    return("la contraseña debe de tener al menos 8 caracteres");
                }
            }
            else
            {
                return("El usuario debe de tener al menos 4 caracteres");
            }
        }
Example #5
0
        public void AgregarNuevoCliente(string nombre, string genero, string estadoCivil, DateTime fechaNacimiento, string escolaridad, string ocupacion, string telefono, string email, string motivos)
        {
            //Patron de creacion
            string telefonovar    = telefono;
            string replacedString = telefono.Replace("(", "");

            telefonovar = replacedString.Replace(")", "");
            telefonovar = telefonovar.Replace("-", "");
            telefonovar = telefonovar.Replace(" ", "");
            var validac     = new Validacion();
            var fechahoy    = DateTime.Today;
            var fechalimite = new DateTime(1900, 1, 1);

            if (validac.Longitud(nombre, 1, 50) && validac.Longitud(genero, 1, 10) && validac.Longitud(estadoCivil, 1, 10) && validac.Longitud(escolaridad, 1, 50) && validac.Longitud(ocupacion, 1, 50) && validac.Longitud(motivos, 1, 100))
            {
                if (validac.FechaMayorA(fechaNacimiento, fechalimite) && validac.FechaMenorA(fechaNacimiento, fechahoy))
                {
                    if (validac.Longitud(telefonovar, 1, 10))
                    {
                        if (validac.Longitud(telefonovar, 7, 10))
                        {
                            if (email == "")
                            {
                                try
                                {
                                    var modeloNuevoCliente = new ModeloNuevoCliente();
                                    modeloNuevoCliente.AgregarNuevoCliente(nombre, genero, estadoCivil, fechaNacimiento, escolaridad, ocupacion, telefono, email, motivos);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(ex.Message);
                                }
                            }
                            else
                            {
                                if (email.Contains("@"))
                                {
                                    if (IsValidEmail(email))
                                    {
                                        try
                                        {
                                            var modeloNuevoCliente = new ModeloNuevoCliente();
                                            modeloNuevoCliente.AgregarNuevoCliente(nombre, genero, estadoCivil, fechaNacimiento, escolaridad, ocupacion, telefono, email, motivos);
                                        }
                                        catch (Exception ex)
                                        {
                                            throw new Exception(ex.Message);
                                        }
                                    }
                                    else
                                    {
                                        error = "Email no valido";
                                        return;
                                    }
                                }
                                else
                                {
                                    error = "Correo no valido";
                                    return;
                                }
                            }
                        }
                        else
                        {
                            error = "Telefono debe tener entre 7 y 10 numeros";
                            return;
                        }
                    }
                    else
                    {
                        if (email == "")
                        {
                            try
                            {
                                var modeloNuevoCliente = new ModeloNuevoCliente();
                                modeloNuevoCliente.AgregarNuevoCliente(nombre, genero, estadoCivil, fechaNacimiento, escolaridad, ocupacion, telefono, email, motivos);
                            }
                            catch (Exception ex)
                            {
                                throw new Exception(ex.Message);
                            }
                        }
                        else
                        {
                            if (email.Contains("@"))
                            {
                                if (IsValidEmail(email))
                                {
                                    try
                                    {
                                        var modeloNuevoCliente = new ModeloNuevoCliente();
                                        modeloNuevoCliente.AgregarNuevoCliente(nombre, genero, estadoCivil, fechaNacimiento, escolaridad, ocupacion, telefono, email, motivos);
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(ex.Message);
                                    }
                                }
                                else
                                {
                                    error = "Email no valido";
                                    return;
                                }
                            }
                            else
                            {
                                error = "Correo no valido";
                                return;
                            }
                        }
                    }
                }
                else
                {
                    error = "Fecha de nacimiento no valida";
                    return;
                }
            }
            else
            {
                error = "Los campos Nombre, Genero, Estado Civil, Escolaridad, Ocupacion y Motivos de Consulta no deben estar vacios";
                return;
            }
        }
Example #6
0
        //Facade
        public void AgregarComida(string nombre, int id1, int id2, int id3, int id4, int id5, string cant1, string cant2, string cant3, string cant4, string cant5)
        {
            bool novacio1 = false;
            bool novacio2 = false;
            bool novacio3 = false;
            bool novacio4 = false;
            bool novacio5 = false;
            bool positivo = true;
            bool noIgual  = true;
            var  validac  = new Validacion();

            if (validac.Longitud(nombre, 1, 50))
            {
                if ((validac.Longitud(id1.ToString(), 1, 50) && validac.Longitud(cant1, 1, 5) && validac.MayorA(id1, 0)) || (validac.Longitud(id2.ToString(), 1, 50) && validac.Longitud(cant2, 1, 5) && validac.MayorA(id2, 0)) || (validac.Longitud(id3.ToString(), 1, 50) && validac.Longitud(cant3, 1, 5) && validac.MayorA(id3, 0)) || (validac.Longitud(id4.ToString(), 1, 50) && validac.Longitud(cant4, 1, 5) && validac.MayorA(id4, 0)) || (validac.Longitud(id5.ToString(), 1, 50) && validac.Longitud(cant5, 1, 5) && validac.MayorA(id5, 0)))
                {
                    if (validac.Longitud(id1.ToString(), 1, 50) && validac.Longitud(cant1, 1, 5))
                    {
                        novacio1 = true;
                    }
                    if (validac.Longitud(id2.ToString(), 1, 50) && validac.Longitud(cant2, 1, 5))
                    {
                        novacio2 = true;
                    }
                    if (validac.Longitud(id3.ToString(), 1, 50) && validac.Longitud(cant3, 1, 5))
                    {
                        novacio3 = true;
                    }
                    if (validac.Longitud(id4.ToString(), 1, 50) && validac.Longitud(cant4, 1, 5))
                    {
                        novacio4 = true;
                    }
                    if (validac.Longitud(id5.ToString(), 1, 50) && validac.Longitud(cant5, 1, 5))
                    {
                        novacio5 = true;
                    }
                    if (novacio1 == true && Convert.ToInt32(cant1) == 0)
                    {
                        positivo = false;
                    }
                    if (novacio2 == true && Convert.ToInt32(cant2) == 0)
                    {
                        positivo = false;
                    }
                    if (novacio3 == true && Convert.ToInt32(cant3) == 0)
                    {
                        positivo = false;
                    }
                    if (novacio4 == true && Convert.ToInt32(cant4) == 0)
                    {
                        positivo = false;
                    }
                    if (novacio5 == true && Convert.ToInt32(cant5) == 0)
                    {
                        positivo = false;
                    }
                    if (novacio1 == true && novacio2 == true && id1 == id2)
                    {
                        noIgual = false;
                    }
                    if (novacio1 == true && novacio3 == true && id1 == id3)
                    {
                        noIgual = false;
                    }
                    if (novacio1 == true && novacio4 == true && id1 == id4)
                    {
                        noIgual = false;
                    }
                    if (novacio1 == true && novacio5 == true && id1 == id5)
                    {
                        noIgual = false;
                    }
                    if (novacio2 == true && novacio3 == true && id2 == id3)
                    {
                        noIgual = false;
                    }
                    if (novacio2 == true && novacio4 == true && id2 == id4)
                    {
                        noIgual = false;
                    }
                    if (novacio2 == true && novacio5 == true && id2 == id5)
                    {
                        noIgual = false;
                    }
                    if (novacio3 == true && novacio4 == true && id3 == id4)
                    {
                        noIgual = false;
                    }
                    if (novacio3 == true && novacio5 == true && id3 == id5)
                    {
                        noIgual = false;
                    }
                    if (novacio4 == true && novacio5 == true && id4 == id5)
                    {
                        noIgual = false;
                    }
                    if (positivo == true && noIgual == true)
                    {
                        try
                        {
                            var modeloComida = new ModeloComida();
                            modeloComida.AgregarComida(nombre, id1, id2, id3, id4, id5, cant1, cant2, cant3, cant4, cant5);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }
                    }
                    else
                    {
                        error = "Las cantidades deben ser mayor a 0 y no puede haber alimentos iguales";
                        return;
                    }
                }
                else
                {
                    error = "Se debe seleccionar al menos un alimento valido y una cantidad";
                    return;
                }
            }
            else
            {
                error = "El campo \"Nombre\" no puede estar vacio";
                return;
            }
        }
Example #7
0
        //Facade
        public void AgregarCita(DateTime fecha, string nombre, string apellido, string telefono, string hora)
        {
            string telefonovar    = telefono;
            string replacedString = telefono.Replace("(", "");

            telefonovar = replacedString.Replace(")", "");
            telefonovar = telefonovar.Replace("-", "");
            telefonovar = telefonovar.Replace(" ", "");
            string horavar = hora;

            horavar = horavar.Replace(":", "");
            horavar = horavar.Replace(" ", "");
            var validac = new Validacion();

            if (validac.Longitud(nombre, 1, 50) == true && validac.Longitud(apellido, 1, 50) == true && validac.Longitud(hora, 1, 50) == true)
            {
                if (validac.Longitud(horavar, 4, 4))
                {
                    string izq = horavar.Substring(0, 2);
                    string der = horavar.Substring(2, 2);
                    if (izq.IndexOf('0') == 0)
                    {
                        izq = izq.Substring(1, 1);
                    }
                    if (der.IndexOf('0') == 0)
                    {
                        der = der.Substring(1, 1);
                    }
                    if (validac.MenorA(Convert.ToInt32(izq), 24) && (validac.MenorA(Convert.ToInt32(der), 60)))
                    {
                        if (validac.FechaMayorIgualA(fecha, DateTime.Today))
                        {
                            if (validac.Longitud(telefonovar, 1, 10))
                            {
                                if (validac.Longitud(telefonovar, 7, 10))
                                {
                                    try
                                    {
                                        var modeloCitas = new ModeloCitas();
                                        modeloCitas.AgregarCita(fecha, nombre, apellido, telefono, hora);
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(ex.Message);
                                    }
                                }
                                else
                                {
                                    error = "Telefono debe tener entre 7 y 10 numeros";
                                    return;
                                }
                            }
                            else
                            {
                                try
                                {
                                    var modeloCitas = new ModeloCitas();
                                    modeloCitas.AgregarCita(fecha, nombre, apellido, telefono, hora);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(ex.Message);
                                }
                            }
                        }
                        else
                        {
                            error = "Fecha invalida";
                            return;
                        }
                    }
                    else
                    {
                        error = "Hora invalida";
                    }
                }
                else
                {
                    error = "Hora invalida";
                    return;
                }
            }
            else
            {
                error = "Los campos con * son obligatorios";
                return;
            }
        }