2
I am starting a project in Webapi and came across a situation that did not know how to define my class of Controller
. I have the following structure
public class Artigo {
public int ArtigoId { get; set; }
public int AutorId { get; set; }
...
public IQueryable<ConteudoArtigo> ConteudosArtigo { get; set; }
}
public class ConteudoArtigo {
public int ConteudoArtigoId { get; set; }
public int ArtigoId { get; set; }
public int IdiomaId { get; set; }
public string Titulo { get; set; }
public string Texto { get; set; }
}
My question is whether I should use two calls POST
to the API
to save each content individually, with the danger of a problem occurring and the chance of the child content not being saved or using a single call to the Controller
father and the same save the content of the child record?
Follow details of modeling
Initially it is worth noting that I simplified the entities not to fill code.
When creating an article, you will create it in one language and this same article can be translated into multiple languages. For each language there will be a record of content.
The idea of having the article as a parent entity was that the comments and evaluations will be of the article, regardless of the language it is
You know that strange model you passed, sincerity did not understand !!!
– user6026
@Fccdias Initially it is worth noting that I simplified the entities to not fill with code. When creating an article, you will create it in one language and this same article can be translated into multiple languages. For each language there will be a record of content. The idea of having the article as a parent entity was that the comments and evaluations will be of the article, regardless of the language it is
– Caputo
You are using
ApiController
to save the code?– Leonel Sanches da Silva
Hello @Ciganomorrisonmendez, I left this project aside for now, but was using Apicontroller to save. I intend to resume it within 15 days
– Caputo