0

Soy nuevo en asp.net mvc, estoy creando una web app "fitness" que permita calcular el BMI y el BF% (porcentaje de grasa corporal).

El usuario vera esto:

<h1>Calculate</h1>

<h2>BMI</h2>

<form>
    <table>
        <tr>
            <td align="right"><b>Weight:</b></td>
            <td align="left"><input type="text" name="Weight" /></td>
        </tr>
        <tr>
            <td align="right"><b>Height:</b></td>
            <td align="left"><input type="text" name="Height" /></td>
        </tr>
        <tr>
            <td align="right"><b>BMI:</b></td>
            <td align="left"><input type="text" name="BMI" /></td>
        </tr>
    </table>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="button" value="Calculate" class="btn btn-default" onclick="location.href='<%: @Url.Action("CalculateBMI", "Measurements") %>'"/>
        </div>
    </div>
</form>

<h2>BF% (aproximated)</h2>
<p>(All the measurements must be taken at the narrowest point)</p>
<form>
    <table>
        <tr>
            <td align="right"><b>Male</b></td>
            <td align="left"><input type="radio" name="Waist" /></td>
            <td align="center"><b>Female</b></td>
            <td align="center"><input type="radio" name="Waist" /></td>
        </tr>
        <tr>
            <td align="right"><b>Height:</b></td>
            <td align="left"><input type="text" name="Height" /></td>
        </tr>
        <tr>
            <td align="right"><b>Waist:</b></td>
            <td align="left"><input type="text" name="Waist" /></td>
        </tr>
        <tr>
            <td align="right"><b>Hip:</b></td>
            <td align="left"><input type="text" name="Hip" /></td>
        </tr>
        <tr>
            <td align="right"><b>Neck:</b></td>
            <td align="left"><input type="text" name="Neck" /></td>
        </tr>
        <tr>
            <td align="right"><b>BF%:</b></td>
            <td align="left"><input type="text" name="BF%" /></td>
        </tr>
    </table>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="button" value="Calculate" class="btn btn-default" onclick="location.href='<%: @Url.Action("CalculateBF", "Measurements") %>'">
        </div>
    </div>
</form>

y al hacer click en el botton calculate, vendra llamado el metodo respectivo desde el controllador Measurements:

public int CalculateBMI(int height, int weigth)
        {

        int BMI = height / (weigth * weigth);

        return BMI;
    }

    public int CalculateBF(String gender,int height, int waist, int hip, int neck)
    {

        int bf;

        if (gender.Equals("male"))
        {
            bf = ((495) / (int)(1.0324 - 0.19077 * Math.Log10(waist - neck) + 0.15456 * Math.Log10(height))) - 450;

            return bf;
        }
        if (gender.Equals("female"))
        {
            bf = (int)((495) / (((1.29579 - 0.35004) * Math.Log10(waist + hip - neck) + 0.22100 * Math.Log10(height)) - 450)) - 450;

            return bf;
        }

        return bf = 0;
    }

Pero no tengo idea de como hacer para que los valores regresen al input text de nombre BMI e BF y como coger los valores de cada input text para hacer los respectivos calculos.

2

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.