Task database structure
incidents -> accounts -> contacts
incident -> account, 1=>M,
account -> contact , 1=> M.
Incident, incident name - primary key, autogenerated, string
Account, Name - > unique string field
Functionality create web api, asp core, ef code first (edited)
Introduce the API to create the following records: contacts, accounts, incidents (edited)
account cannot be created without contact
incident cannot be created without account
logic for incident creation method
Request example request body
{
account name,
contact first name,
contact last name,
contact email, // unique identifier,
incident description,
}
Validation if account name is not in the system -> API must return 404 – NotFound
if contact is in the system (check by email) -> update contact record, link contact to account if it has not been linked prevoisly.
Otherwise, -create new contact with first name, last name, email and
-link just created contact to the account
-create new incident, for account and populate incident description field