Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contacts management proposal #1623

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

contacts management proposal #1623

wants to merge 6 commits into from

Conversation

DmyMi
Copy link
Contributor

@DmyMi DmyMi commented Jan 3, 2025

Note

This is only a part for changes for approach review

  • Implemented contacts owned entity using the following relationship.
---
title: Contacts
---
erDiagram

    WORKSHOP ||--|{ CONTACT : "owns many"
    CONTACT ||--|| ADDRESS : "owns one"
    CONTACT ||--|{ PHONE : "owns many"
    CONTACT ||--|{ EMAIL : "owns many"
    CONTACT ||--|{ SOCIALLINK : "owns many"

    WORKSHOP {
        long Id
        string Name
    }

    CONTACT {
        long Id
        string Title
    }

    ADDRESS {
        long Id
        string Street
        string BuildingNumber
    }

    PHONE {
        long Id
        string Number
        string Type
    }

    EMAIL {
        long Id
        string Address
        string Type
    }

    SOCIALLINK {
        long Id
        string Url
        string Type
    }

Loading
  • Created a separate service (composition over inheritance) to manage contacts. Strongly typed on both sides using interfaces to make sure we are mapping contacts from same entity-dto combo (as we will have multiple entities onwing contacts). Using a generic approach to instantiate it.
  • As entities are owned - no need to explicitly save them or manage with repository.

Question: Current approach does not expose Ids and uses content comparison. It might lead to deletion and creation of new records in db, e.g., change one letter in email => delete old record and create new. If it's ok - we can leave it as it is simpler than managing Ids.


public void ProcessCreate(TEntity existingEntity, TDto dto)
{
existingEntity.Contacts = mapper.Map<List<Contacts>>(dto.Contacts);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No checks for duplicates

await ChangeTeachers(currentWorkshop, dto.Teachers ?? new List<TeacherDTO>()).ConfigureAwait(false);
await ChangeTeachers(currentWorkshop, dto.Teachers ?? []).ConfigureAwait(false);

contactsService.ProcessUpdate(currentWorkshop, dto);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be part of ChangeTeachers

Copy link
Contributor

@VadymLevkovskyi VadymLevkovskyi Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not done - was it missed or were there any reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VadymLevkovskyi Teachers are not related to contacts, as we're providing contacts of the workshop itself, not its teachers. Also later teachers will be completely changed to new employees, so instead of adding teachers as value objects they are going to be completely separate and indepentent entity.

Copy link
Contributor

@VadymLevkovskyi VadymLevkovskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented a bit. Mainly about naming and stricter typing

@DmyMi DmyMi marked this pull request as ready for review January 7, 2025 11:13
@DmyMi DmyMi force-pushed the dmin/contacts_entity branch from 272eb50 to 614c2a5 Compare January 8, 2025 13:14
Copy link

sonarqubecloud bot commented Jan 8, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
48.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants