Register with repeated fields, how to do it?

1

I have a system registry that I am developing that will have repeated fields, I would like help in this implementation.

This screen is called Sequence that has the following fields

Date

Sequence Number

Lot

Name = A side | Type | Camera

Name = B Side | Type | Camera

All the Sequence register that will be performed will always have Side A and Side B.

IcreatedaclasssothatViewscanseetheclassescorrespondingtotheregister.

SequenceViewModelclass

usingSystem.Collections.Generic;usingSystem.ComponentModel.DataAnnotations;namespaceGerenciamentoDeQuartos.Models{publicclassSequenciaViewModel{publicSequenciaViewModel(){Lado_A.Nome="Lado A";
            Lado_B.Nome = "Lado B";
        }

        public Lote Lote { get; set; }
        public List<Lote> LoteList { get; set; }

        public Sequencia Sequencia { get; set; }
        public List<Sequencia> SequenciaList { get; set; }

        [Display(Name = "Tipo Lado A")]
        [Required(ErrorMessage = "O Campo {0} é requirido!")]
        [Range(1, double.MaxValue, ErrorMessage = "Selecione o {0} corretamente!")]
        public Lado Lado_A { get; set; }

        [Display(Name = "Tipo Lado B")]
        [Required(ErrorMessage = "O Campo {0} é requirido!")]
        [Range(1, double.MaxValue, ErrorMessage = "Selecione o {0} corretamente!")]
        public Lado Lado_B { get; set; }
        public List<Lado> LadoList { get; set; }

        [Display(Name = "Camara A")]
        [Required(ErrorMessage = "O Campo {0} é requirido!")]
        [Range(1, double.MaxValue, ErrorMessage = "Selecione o {0} corretamente!")]
        public Camara Camara_A { get; set; }

        [Display(Name = "Camara B")]
        [Required(ErrorMessage = "O Campo {0} é requirido!")]
        [Range(1, double.MaxValue, ErrorMessage = "Selecione o {0} corretamente!")]
        public Camara Camara_B { get; set; }
        public List<Camara> CamaraList { get; set; }
    }
}

Sequence register view

@model GerenciamentoDeQuartos.Models.SequenciaViewModel

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>Sequencia</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.Lado_A.Nome)
        @Html.HiddenFor(model => model.Lado_B.Nome)
        <div class="form-group">
            @Html.LabelFor(model => model.Sequencia.DataAbate, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Sequencia.DataAbate, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Sequencia.DataAbate, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Sequencia.NumeroSequencia, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Sequencia.NumeroSequencia, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Sequencia.NumeroSequencia, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Sequencia.Lote, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Sequencia.Lote, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Sequencia.Lote, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Lado_A.Nome, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Lado_A.Nome, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Lado_A.Nome, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Lado_A, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("TipoLadoId", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Lado_A.TipoLadoId, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Camara_A, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("CamaraId", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Lado_A.CamaraId, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Lado_B.Nome, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Lado_A.Nome, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Lado_A.Nome, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Lado_B.TipoLadoId, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("TipoLadoId", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Lado_B.TipoLadoId, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Camara_B, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("CamaraId", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Lado_B.CamaraId, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
    
asked by anonymous 03.06.2018 / 17:16

0 answers