I'm starting a WebApi project and I came across a situation that I did not know how to set my Controller
class. 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 POST
calls to API
to save each content individually, with the danger of a problem occurring and having the chance of child content not being saved or using a single call to the % with parent% and the same save the contents of the child record?
Following modeling details
-
Initially it is good to point out that I simplified the entities to not fill with code.
-
When creating an article, you will create it in one language and this article can be translated into multiple languages. A content record will exist for each language.
-
The idea of having the article as parent was that the comments and ratings will be of the article, regardless of the language it is