Closed Nhawdge closed 4 years ago
ok so I've created a new branch called "interface" to work on the database service. I also did a bit of reading around CRUD and have a few questions before launching into the code:
Still getting my head around this but I think everything is starting to coalesce in my brain (?!)
Thanks!
Also, haha you're learning!
haha uh oh learning?! Just getting into the process a bit more:
Before writing the Get/Post methods in the DatabaseServices file, will i need to create some new View Models in the Models folder? e.g RecipeViewModel, InstructionsViewModel, and IngredientsViewModel
Then in each one create a model class? e.g. :
public static class RecipeViewModel
{
public string id { get; set; }
public string name { get; set; }
public date dateAdded { get; set; }
public string author {get; set;}
public InstructionsViewModel Instructions { get; set; }
public IngredientsViewModel Ingredients { get; set }
}
I may be waaay off track but I found a tutorial online I am trying to follow/apply to our recipe tracker...
Thanks!
Yes, this is totally correct and is pretty much our next step. We need C# models to connect to the Knockout models we built.
Hi John, I'm afraid I haven't been very successful in the challenge this week...I have tried to read about creating GET and POST requests in C# but have ended up going round in circles and haven't managed to really get started :s Perhaps we could go through this on Sunday?
That sounds great. We'll put it on the agenda!
I'm calling this completed. I'm gonna open a new ticket for making the rest work
When we work with .NET MVC we have several layers. The front end is split into MVC, Model View Controller. We worked with knockout to handle the Model. We're using HTML/KO to handle the View, and we've got .NET MVC Handling the controller portion. That covers the bulk of the front end of the site.
Now our back end is a bit different and we need 2 key layers. The code portion, and the data portion. A couple weeks ago we (you) build out a couple database tables, Now we want to make our data layer accessible via code. Normally the best way to handle this is with a service. A service isn't some magically word or tool, it's just a way to describe code.
Take this example service below
When we work with abstracting data, it's important to use
Interface
s They allow another developer to mimic your code for another system. For example, what if we switched from Mysql, to SQL Server, But we wanted both to be available. Well we can use an interface to handle interactions without rewriting every connected piece of code.YOUR GOAL
is to implement the following interface to any degree of success
Hints (Spoilers)
* [x] Create a new file for your interface and paste the above code * [x] Create a new folder and file for your service. * Note where the words 'static' are at * [x] Add the interface to your class `class MyDataBaseClase : IDatabaseConnection ` * [x] Handle the errors until it builds.