0
I have the following class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Dynamic;
namespace Model
{
class PromocaoQtdeVendidaModel
{
private int idPromocaoQtdeVendida;
private String descricao;
private List<ProdutoModel> listaProdutos = new List<ProdutoModel>();
private EmpresaModel empresa = new EmpresaModel();
private DateTime dataCadastro;
private DateTime dataInicio;
private DateTime dataFim;
private int quantidadeMix;
public DateTime DataFim
{
get { return dataFim; }
set { dataFim = value; }
}
public DateTime DataInicio
{
get { return dataInicio; }
set { dataInicio = value; }
}
public DateTime DataCadastro
{
get { return dataCadastro; }
set { dataCadastro = value; }
}
public EmpresaModel Empresa
{
get { return empresa; }
set { empresa = value; }
}
public int IdPromocaoQtdeVendida
{
get { return idPromocaoQtdeVendida; }
set { idPromocaoQtdeVendida = value; }
}
public String Descricao
{
get { return descricao; }
set { descricao = value; }
}
public List<ProdutoModel> ListaProdutos
{
get { return listaProdutos; }
set { listaProdutos = value; }
}
}
}
and I need the listProduct to have an INT quantityItem I’m trying to do it this way:
private List<int> quantidadeIte = new List<int>();
public List<ProdutoModel> ListaProdutos
{
get { return listaProdutos; }
set {
listaProdutos.AddRange(quantidadeItem);
listaProdutos = value;
}
}
but, is giving the following error:
I didn’t want to change my model product, because, I will use this int only in this model.
someone knows how it could do?
Young man, can you [dit] your question and be more specific? Your code doesn’t make sense, so explain to us what your problem is and how you think you can solve it, so we can show you how to do it in code.
– Jéf Bueno
Lilloh, I recommend reading about the Viewmodel standard: http://www.eduardopires.net.br/2013/08/asp-net-mvc-view-model-pattern-quando-e-como-use/
– Artur Trapp
@Arturotemplário saw the link that you gave me, I believe that this meets what I need. I was thinking that I could make a get and a set inside a model (Product) by the model (Promotion) but, by what I researched it is not possible.
– Tozzi
@LINQ I don’t know how to further my doubt. But, basically I have a PRODUCT MODEL (that you get the product attributes) and I need to create a PROMOTION MODEL within the promotion will have a product list because I need that within the product list has a minimum quantity int... improved?
– Tozzi