GFlisch / Arc4u.Guidance.Doc

Other
5 stars 1 forks source link

Bug when following Guidance flow after adding a Delete entity #193

Open poldepuysseleyr opened 1 year ago

poldepuysseleyr commented 1 year ago

Describe the bug

Multiple bugs happen when following the Guidance flow after adding a delete entity to the domain layer.

First bug: Bug is situated in the SaveValidator class after adding a business class from an existing entity. Rule for DeletedOn is making the validator crash in method ValidateAsync in ValidatorBase when inserting a new entity. This happens because the rule is checking the value of DeletedOn, but DeletedOn is a nullable property.

Second bug(which will happen if you fix the issue above): If you try to save an entity after fixing the issue above, SQL will not allow you because you are trying to insert a null value into the database because DeletedBy and DeletedOn is still required in the database mapping configuration.

Third bug(or maybe a feature): The DeleteValidator should contain the DeletedBy and DeletedOn rules described above.

Fourth bug: UpdatedBy on the entity should also be nullable, because in the delete scenario you never set the UpdatedBy and UpdatedOn properties but they are still required in the database, also resulting in an exception.

Feature request: Entity is not loaded before doing an update, would be nice if the entity is pre-loaded in the BL so the CreatedBy and CreatedOn values are copied from the existing entity.

To Reproduce Steps to reproduce the behavior:

  1. Add a delete entity to the domain layer.
  2. Add from an existing entity business classes on the database layer.
  3. Validators get created with all the database mapping as well.
  4. When trying to insert a new entity through swagger, you always get a null reference exception.

Expected behavior First bug: Deleted lines should be removed(since you use a DeleteValidator when deleting an entity)

Second bug: Make DeletedBy nullabe in the entity and make DeletedBy and DeletedOn not required in the mapping configuration. DeletedBy should be an explicit nullable string, otherwise you get issues with the Graph object.

Third bug: DeletedBy and DeletedOn rules should be present in the DeleteValidator

Fourth bug: Make UpdatedBy nullabe in the entity and make UpdatedBy and UpdatedOn not required in the mapping configuration. UpdatedBy should be an explicit nullable string, otherwise you get issues with the Graph object.

Screenshots First bug: image

Second bug: image

Desktop:

rdarko commented 1 year ago

will be tackled with the BL refacotring