How to return values from an undeclared View in Model to Contoller by post method

1

My controller is declared according to the code below:

public ActionResult Create([Bind(Include = "a,b,c,d,e")] Proposal proposal, int prjId, int[] array)
{
    if (ModelState.IsValid)
    {   
        proposal.f = prjId;
        db.Proposals.Add(proposal);
        db.SaveChanges();
        foreach(var x in step)
        {
            var price = new Price();
            price.a = x.step;
            price.b = x.menday;
            price.c = x.value;
            db.SalveChanges();
        }
        return RedirectToAction("Index");
    }
    return View(proposal);
}

View Code:

   <div class="container margin-top-0">
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h2 class="panel-title">Proposta de Trabalho</h2>
        </div>
        <section class="panel-body">
            <div class="row-content">
                <section class="col-lg-12">
                    @Html.LabelFor(model => model.a, htmlAttributes: new { @class = "control-label" })
                    <section class="input-group col-lg-12">
                        @Html.TextAreaFor(model => model.a, new { @class = "form-control", @cols = 80, @rows = 10, @placeHolder = "Informe aqui todos os detalhes da prestação da proposta de prestação de serviços!", onkeyup = "limite_textarea_ProposalDescription(this.value)", id = "text_ProposalDescription" })
                        @Html.ValidationMessageFor(model => model.a, "", new { @class = "text-danger" })
                    </section>
                    <div class="text-right">
                        <span id="cont_ProposalDescription" class="small">2500</span>
                    </div>
                </section>
            </div>
            <div class="row-content">
                <section class="col-lg-3">
                    @Html.LabelFor(model => model.b, htmlAttributes: new { @class = "control-label" })
                    <section class="input-group col-lg-12">
                        @Html.EditorFor(model => model.b, new { htmlAttributes = new { @class = "form-control", @placeholder = "Horas" } })
                        @Html.ValidationMessageFor(model => model.b, "", new { @class = "text-danger" })
                    </section>
                </section>
                <section class="col-lg-3">
                    @Html.LabelFor(model => model.c, htmlAttributes: new { @class = "control-label" })
                    <section class="input-group col-lg-12">
                        @Html.EditorFor(model => model.c, new { htmlAttributes = new { @class = "form-control", @placeHolder = "Dias Trabalho" } })
                        @Html.ValidationMessageFor(model => model.c, "", new { @class = "text-danger" })
                    </section>
                </section>
                <section class="col-lg-3">
                    @Html.LabelFor(model => model.d, htmlAttributes: new { @class = "control-label" })
                    <div class="input-group col-lg-12">
                        @Html.EditorFor(model => model.d, new { htmlAttributes = new { @class = "form-control", @placeholder = "Valor Total" } })
                        @Html.ValidationMessageFor(model => model.d, "", new { @class = "text-danger" })
                    </div>
                </section>
                <section class="col-lg-3">
                    @Html.LabelFor(model => model.e, htmlAttributes: new { @class = "control-label" })
                    <div class="input-group col-lg-12">
                        @Html.EditorFor(model => model.e, new { htmlAttributes = new { @class = "form-control", @placeholder = "Valor Total" } })
                        @Html.ValidationMessageFor(model => model.e, "", new { @class = "text-danger" })
                    </div>
                </section>
                <input id="array" value="" hidden/>
                <input id="prjId" value="23" hidden />
            </div>
        </section>
    </div>
    <div class="form-actions">
        <div class="col-md-12">
            <input type="submit" value="Criar Proposta" class="btn btn-lg btn-raised btn-primary center-block" />
        </div>
    </div>
}
  @section scripts{
<script type="text/javascript">
function array() {
        var linhas = document.getElementsByName('StepValue').length;
        var stepArray = new Array("Step","Menday","Valor");
        for (i = 0; i < linhas; i++) {
            stepArray.push(
                [document.getElementById('Step' + (i + 1)).value, document.getElementById('Menday' + (i + 1)).value, document.getElementById('Valor' + (i + 1)).value]
            );
        }            
        document.querySelector("[id='array']").value = stepArray;
    }
</script>
}

The problem is that I am not able to pass the values of "prjId" and "array" that are dynamic and are not declared in the model. Can someone help me?

    
asked by anonymous 27.09.2017 / 19:45

0 answers