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

Create initial api for CRUD actions on DB #3

Merged
merged 15 commits into from
Apr 5, 2016
Merged

Conversation

tdshipley
Copy link
Owner

Github Issue: #2

Created the api to handle CRUD actions on the DB using EF7. Not the most efficient solution; could use automapper for example to handle the conversion of model <---> view model, EF code is not efficient but works.

@tdshipley
Copy link
Owner Author

Created issue #4 to track the refactoring of this code and ideas. However I am happy for now with it as I just wanted to get a working version complete which I can then iterate on as I learn more about ASP.NET Core 1.0.

Will close PR once I have had a chance to throughly test.

@tdshipley tdshipley changed the title Create initial api Create initial api for CRUD actions on DB Apr 3, 2016
@@ -0,0 +1,45 @@
{
Copy link
Owner Author

Choose a reason for hiding this comment

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

This can be deleted - debugging in VSCode for ASP.NET Core 1.0 apps isn't supported yet and will be brought in by a plugin.

See microsoft/vscode#275 and https://blogs.msdn.microsoft.com/visualstudioalm/2016/03/10/experimental-net-core-debugging-in-vs-code/

[HttpPost]
[Route("{id}")]
public JsonResult Update(int id, [FromBody] ExerciseViewModel model)
{
Copy link
Owner Author

Choose a reason for hiding this comment

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

Add null check for model

@tdshipley
Copy link
Owner Author

Summary

Mostly just need to rename things to make the code clearer. Should also:

  • Rename all ViewModel variables to vm
  • Update variable names which contain ViewModel or its variants to vm
  • Update some of the other variable names to make them more clear.
  • Run the code through a linter to fix spacing - my VS code isn't currently doing this well.
  • Move assignments out of the if model valid block - as any errors in the assignments won't be caught!
  • Update the TODO's for EF7 navigation properties to use the Include method

@tdshipley
Copy link
Owner Author

Tested locally and all works.

@tdshipley tdshipley merged commit cc7b34f into master Apr 5, 2016
@tdshipley tdshipley deleted the create_initial_api branch May 12, 2016 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant