Implement CRUD operations in UserController#51
Open
github-cloudlabsuser-2113 wants to merge 2 commits into
Open
Implement CRUD operations in UserController#51github-cloudlabsuser-2113 wants to merge 2 commits into
github-cloudlabsuser-2113 wants to merge 2 commits into
Conversation
This commit introduces a series of significant updates to the UserController.cs and adds unit tests in UserControllerTests.cs. In UserController.cs, we have implemented CRUD operations fo#r the User model, including methods for Index, Details, Create (GET and POST), Edit (GET and POST), and Delete (GET and POST). These methods interact with a static list named `userlist` that serves as a temporary database, facilitating operations like adding, editing, and deleting users. Additionally, the commit includes the creation of the namespace `CRUD_application_2.Controllers` to house the UserController class. For UserControllerTests.cs, we have added unit tests using NUnit and Moq to verify the functionality of the UserController methods. The tests cover the Index, Details, and Create methods, ensuring they behave as expected when interacting with the static `userlist`. These tests include scenarios where users are successfully found, added, or not found, leading to appropriate responses such as views with user data or `HttpNotFound` results. Overall, this commit significantly enhances the application's ability to manage users through the UserController and ensures the reliability of these features through comprehensive unit testing. Refactor UserController & add unit tests - Refactored UserController.cs by removing unnecessary comments and implementing core CRUD functionalities for user management. This includes enhancements to the Index, Details, Create, Edit, and Delete actions to ensure they perform as expected, handling both success and error scenarios appropriately. - Enhanced the Index action to return a view with a list of all users, and the Details action now searches for a user by ID, returning user details or a HttpNotFound result based on the user's existence. - Improved the Create action with GET and POST handlers for adding new users, including error handling. Similarly, the Edit action has been updated to allow for user information updates with proper error checking. The Delete action now supports user removal with confirmation. - Introduced UserControllerTests.cs, utilizing the NUnit framework for unit testing the UserController. This includes setting up a test environment with a simulated user list and implementing tests for the Index, Details, and Create actions to verify their functionality and error handling. - Utilized Moq and NUnit in the test class for mocking dependencies and assertions, enhancing the reliability of the tests.
Added a new ARM template `deploy.json` for deploying an Azure SQL Server and a SQL Database, including configurations like version, collation, and maxSizeBytes. A parameters file `deploy.parameters.json` was also added to provide placeholder values for the deployment parameters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit introduces a series of significant updates to the UserController.cs and adds unit tests in UserControllerTests.cs. In UserController.cs, we have implemented CRUD operations fo#r the User model, including methods for Index, Details, Create (GET and POST), Edit (GET and POST), and Delete (GET and POST). These methods interact with a static list named
userlistthat serves as a temporary database, facilitating operations like adding, editing, and deleting users. Additionally, the commit includes the creation of the namespaceCRUD_application_2.Controllersto house the UserController class.For UserControllerTests.cs, we have added unit tests using NUnit and Moq to verify the functionality of the UserController methods. The tests cover the Index, Details, and Create methods, ensuring they behave as expected when interacting with the static
userlist. These tests include scenarios where users are successfully found, added, or not found, leading to appropriate responses such as views with user data orHttpNotFoundresults.Overall, this commit significantly enhances the application's ability to manage users through the UserController and ensures the reliability of these features through comprehensive unit testing.
Refactor UserController & add unit tests