Hi,
I am trying to figure out how much I can push AutoCRUD before I have to create a service to handle scenarios.
I have a type, Company
, it looks something like this:
public class Company : AuditBase
{
[AutoIncrement]
public long Id { get; set; }
[Index]
public string Name { get; set; }
public string Phone { get; set; }
public string Profile { get; set; }
public string LicenseNumber { get; set; }
public string Website { get; set; }
public string SupportEmail { get; set; }
public string AppInviteCode { get; set; }
public string LogoFile { get; set; }
[Reference]
public Industry Industry { get; set; }
public long IndustryId { get; set; }
public string Message { get; set; }
public string TermsAndConditions { get; set; }
[Reference]
public List<TaxRate> TaxRates { get; set; } = new List<TaxRate>();
[Reference]
public List<AddressCompany> Addresses { get; set; }
}
Industry
looks like this:
public class Industry
{
[AutoIncrement]
public long Id { get; set; }
public string Name { get; set; }
}
TaxRate
:
public class TaxRate
{
[AutoIncrement]
public long Id { get; set; }
public string Name { get; set; }
[Reference]
public Company Company { get; set; }
public long CompanyId { get; set; }
}
And finally, AddressCompany
:
public class AddressCompany : AuditBase
{
[AutoIncrement]
public long Id { get; set; }
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string AddressLine3 { get; set; }
public string AddressLine4 { get; set; }
public string Locality { get; set; }
public string Region { get; set; }
public string ZipCode { get; set; }
public string Country { get; set; }
public string Map { get; set; }
public long CompanyId { get; set; }
}
My question is whether there is some way that I can configure AutoCRUD so that the following DTO would map to not just Company table but also the other tables (Industry and Address) in one request.
[Route("/company", "POST")]
[AutoApply(Behavior.AuditCreate)]
public class CreateCompany : ICreateDb<Company>, IReturn<Company>
{
public string Name { get; set; }
public string Phone { get; set; }
public string Profile { get; set; }
public string LicenseNumber { get; set; }
public string Website { get; set; }
public string SupportEmail { get; set; }
public string AppInviteCode { get; set; }
public string LogoFile { get; set; }
public string Message { get; set; }
public string TermsAndConditions { get; set; }
[ApiAllowableValues(typeof(Industry))]
public Industry Industry { get; set; }
public List<AddressCompany> Address { get; set; }
}
I can simplify Company and create separate DTOs to achieve the same result but would like to know if there is a better way to get this done and take advantage of AutoQuery CRUD.