0
I’m starting in mobile development and I’m doing a category control system. Where I give possibility to do various levels of categories.
My entity was as follows:
public int CategoriaId { get; set; }
public string Descricao { get; set; }
public int? CategoriaPaiId { get; set; }
public virtual Categoria CategoriaPai { get; set; }
public virtual ICollection<Categoria> CategoriasFilho { get; set; }
My doubts are being raised ViewModel
I started programming and so far it’s like this:
[Key]
public int CategoriaId { get; set; }
[Display(Name = "Categoria pai")]
public string CategoriaPaiId { get; set; }
[Display(Name = "Descrição da categoria")]
[Required(ErrorMessage = "Descrição obrigatória.")]
public string Descricao { get; set; }
[Display(Name = "Ativo")]
public bool Status { get; set; }
How can I conclude this ?
I don’t understand your question. Why you need to create a
ViewModel
?– Leonel Sanches da Silva
Because here I use viewmodel to instantiate my object
– Renan Rodrigues
Yes, but why? What is the point of this? A
ViewModel
is almost identical toModel
. There’s no need for that if they’re the same, or almost the same.– Leonel Sanches da Silva
I don’t know the correct explanation, as I said I’m new, in the standard project which I’m following he has two view models, which he calls Categoriaviewmodel and Managementcategory viewmodel, in it are the described data of my entity, I need to describe in it a list, of categories
– Renan Rodrigues
Well, this pattern is long-winded and I believe you can simplify it. I will direct an answer without considering
ViewModels
, okay?– Leonel Sanches da Silva
OK @Gypsy Rrisonmendez
– Renan Rodrigues