1
I have a situation that I would like to use the most correct (elegant) way to implement. The scenario is as follows:
I’m building a Helpdesk system where Tickets are stored in one table (and consequently have their own Model) and Ticket Evolutions are stored in another.
The implementation I’m doing is with C# using MVC and Razor
I’ve already done the View
ticket listing and clicking on it I go to another that presents details with information of the title, content, sector that registered and user.
I’d like to bring along this View
details the history of evolutions (and even register new evolutions related to the ticket) and it is precisely in this that I am having difficulties (gather in a single View
information from model
ticket and the model
developments).
Below are the structures assembled for better understanding: MODELS
public class ticket
{
[Key]
public int id_ticket { get; set; }
public int id_setor { get; set; }
public int id_usuario { get; set; }
public string assunto_ticket { get; set; }
public string prioridade_ticket { get; set; }
public string mensagem_ticket { get; set; }
public DateTime data_ticket { get; set; }
public string status_ticket { get; set; }
}
public class Evolucao
{
[Key]
public int id_evolucao { get; set; }
public int id_ticket { get; set; }
public int id_usuario { get; set; }
public string texto_evolucao { get; set; }
public DateTime data_evolucao { get; set; }
}
I believe that the relationship between models remains. Type in Evolucao public virtual ticket id_ticket { get; set; }
– Dorathoto
another suggestion use the standard name pattern already standardized for models. instead of id_evolution the correct one would be Evolucaoid so you won’t need to use [Foreignkey("id_ticket")] in the models' relations, nor [Key] because with the Id ending he already knows that he is Key
– Dorathoto