//Facade public void AgregarAlimento(string nombre, string energia, string hidratos, string grasa, string proteinas) { var validac = new Validacion(); if (validac.Longitud(nombre, 1, 50) && validac.Longitud(energia, 1, 6) && validac.Longitud(hidratos, 1, 5) && validac.Longitud(grasa, 1, 5) && validac.Longitud(proteinas, 1, 5)) { if (validac.MayorA(Convert.ToInt32(energia), 0) && validac.MayorA(Convert.ToInt32(hidratos), 0) && validac.MayorA(Convert.ToInt32(grasa), 0) && validac.MayorA(Convert.ToInt32(proteinas), 0)) { try { var modeloAlimento = new ModeloAlimento(); modeloAlimento.AgregarAlimento(nombre, energia, hidratos, grasa, proteinas); } catch (Exception ex) { throw new Exception(ex.Message); } } else { error = "Los campos despues de nombre deben ser mayores a cero"; return; } } else { error = "Los campos con * son obligatorios"; return; } }
public void AgregarDatosCita(string grasaVis, string CMB, string cirCad, string bodyAge, string cirCin, string musculoPorc, string grasaPorc, string IMC, string peso, DateTime fecha, int id) { 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.MenorA(Convert.ToInt32(peso), 801) && validac.MenorA(Convert.ToInt32(grasaPorc), 101) && validac.MenorA(Convert.ToInt32(musculoPorc), 101) && validac.MenorA(Convert.ToInt32(bodyAge), 101)) { if (validac.FechaMayorIgualA(fecha, DateTime.Today)) { try { var modelodc = new ModeloDatosxCita(); modelodc.AgregarDatosCita(grasaVis, CMB, cirCad, bodyAge, cirCin, musculoPorc, grasaPorc, IMC, peso, fecha, id); } catch (Exception ex) { throw new Exception(ex.Message); } } else { error = "Fecha invalida"; return; } } else { error = "Alguna cantidad paso el rango establecido"; return; } } else { error = "Las cantidades deben ser mayor a cero"; return; } } else { error = "Los campos con * no deben estar vacios"; return; } }
//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; } }