I continued my progress with fixing delete function, which suppose to remove linked data in multiple table across the database. The failure of delete function due to certain entity are set as foreign key of other table. This problem is solved by setting null value for related foreign key in delete function. As the value of foreign key is null, deletion is allowed as how it suppose to behave.
Next, I alter sequence of textbox in View class. To ensure best user experience when they uses hotkey “Tab” to navigates over to next textbox available.
Then, Remove validation made in ViewModel class and implement it in repository class. Allowing EF core throw error whenever unique entity is input multiple time. The error will be catch, hence, prompt dialog box to notify user of application. This way is a better implementation reduce number of code, however it cause few issue in application. Issue such as user unable to create new user after error popped up to indicate similar user id appears in database.
In conjunction, RepositoryActualDbTests class is created to mock my situation. I arrange declaration, execute three seperate input ( 1st input : id = 1, 2nd input : id = 1, 3rd input : id = 2 ) , and assert expected behaviour ( Total of 2 input should be saved input database ). After quite an amount of testing and struggling, the bug is then fixed, however it requires chain fix in code. Therefore, my supervisor advice me to try out a different implementation for my create function by mocking a test.
