3
I am doing a project in Visual Studio 2013, with Entityframework version 6.1.3, MVC 4.5.0.0 and using Viewmodel.
I am programming a page that is called payment condition. The creation page will have a text field nome
, 2 radiobuttons
: "the view" and "on time". If the user selects the view nothing will happen.
Now, if the radiobutton
"In time" is selected, a button will appear to add textbox
es of the days to be filled. I need to make this schedule to add the textbox
es as you click the add days button and then make a function to record in the bank.
I think the function of the Add Days button I can do in Jquery, and then the creation button that will add a function in the database Controller.
I know jquery, add the text boxes, now I’m a little lost in the part of c#, the save in the bank made in Controller.
the code below is from my viewmodel:
[Key]
[DisplayName("Id")]
public int CondicaoPagamentoId { get; set; }
[Required(ErrorMessageResourceName = "PropertyValueRequired", ErrorMessageResourceType = typeof(DataAnnotationsResources))]
[MinLength(DataConfig.DATABASE_MIN_LENGTH_DEFAULT, ErrorMessageResourceName = "MinLengthAttribute_ValidationError", ErrorMessageResourceType = typeof(DataAnnotationsResources))]
[MaxLength(DataConfig.DATABASE_MAX_LENGTH_DEFAULT, ErrorMessageResourceName = "MaxLengthAttribute_ValidationError", ErrorMessageResourceType = typeof(DataAnnotationsResources))]
[DisplayName("Nome")]
public string Nome { get; set; }
[Required(ErrorMessageResourceName = "PropertyValueRequired", ErrorMessageResourceType = typeof(DataAnnotationsResources))]
[MinLength(DataConfig.DATABASE_MIN_LENGTH_DEFAULT, ErrorMessageResourceName = "MinLengthAttribute_ValidationError", ErrorMessageResourceType = typeof(DataAnnotationsResources))]
[MaxLength(DataConfig.DATABASE_MAX_LENGTH_DEFAULT, ErrorMessageResourceName = "MaxLengthAttribute_ValidationError", ErrorMessageResourceType = typeof(DataAnnotationsResources))]
[DisplayName("Tipo")]
public bool Tipo { get; set; }
[Required(ErrorMessageResourceName = "PropertyValueRequired", ErrorMessageResourceType = typeof(DataAnnotationsResources))]
[DisplayName("Dias")]
public int CondicaoPagamentoDiasId { get; set; }
public virtual CondicaoPagamentoDiasViewModel CondicaoPagamentoDias { get; set; }
public virtual IEnumerable<CondicaoPagamentoDiasViewModel> CondicaoPagamentoDiass { get; set; }
[DisplayName("Cadastrado por")]
public int UsuarioCadastroId { get; set; }
public virtual UsuarioViewModel UsuarioCadastro { get; set; }
[DisplayName("Data de Cadastro")]
public DateTime DataCadastro { get; set; }
the addition is made by:
this.add(objeto)
The path is using the Nuget package called Begincollectionitem. Here on the website we have these questions and answers about this package. If you can, edit your question by placing code such as your View, of your Viewmodel, etc., so that I can give a more objective orientation.
– Leonel Sanches da Silva
I didn’t understand which part is "lost", you already have some request, method or something to save the data ?
– Thiago Friedman
Thiago I save the object: this.add(object), usually. But in this specific case of my question I have two tables (condicaopagamento to keep the name and the type (term or view) and another to save the days (30,90,...) condicaopagamentodias).
– jp_almeida
I don’t know how I’m going to add the days, since it will be a dynamic thing. And not just an object.
– jp_almeida
I believe that be this that you are looking for. Look at the comment of the Gypsy, which has many other examples. In case none of them answer you, post more information on how your
controller
and itsview
, to make it easier to help you.– Randrade