Post Put And Delete Requet

22 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.42
List Price:  €64.99
You save:  €18.57
£39.83
List Price:  £55.77
You save:  £15.93
CA$68.34
List Price:  CA$95.68
You save:  CA$27.34
A$75.68
List Price:  A$105.96
You save:  A$30.28
S$67.48
List Price:  S$94.48
You save:  S$27
HK$390.53
List Price:  HK$546.78
You save:  HK$156.24
CHF 45.23
List Price:  CHF 63.33
You save:  CHF 18.09
NOK kr543.62
List Price:  NOK kr761.11
You save:  NOK kr217.49
DKK kr346.42
List Price:  DKK kr485.02
You save:  DKK kr138.59
NZ$83.17
List Price:  NZ$116.44
You save:  NZ$33.27
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,471.12
List Price:  ৳7,660.01
You save:  ৳2,188.88
₹4,168.17
List Price:  ₹5,835.78
You save:  ₹1,667.60
RM236.95
List Price:  RM331.75
You save:  RM94.80
₦61,737.65
List Price:  ₦86,437.65
You save:  ₦24,700
₨13,922.21
List Price:  ₨19,492.21
You save:  ₨5,570
฿1,837.56
List Price:  ฿2,572.74
You save:  ฿735.17
₺1,617.36
List Price:  ₺2,264.43
You save:  ₺647.07
B$253.57
List Price:  B$355.02
You save:  B$101.45
R925.26
List Price:  R1,295.44
You save:  R370.18
Лв90.75
List Price:  Лв127.05
You save:  Лв36.30
₩67,788.68
List Price:  ₩94,909.58
You save:  ₩27,120.90
₪185.81
List Price:  ₪260.15
You save:  ₪74.34
₱2,852.60
List Price:  ₱3,993.87
You save:  ₱1,141.27
¥7,651.71
List Price:  ¥10,713.01
You save:  ¥3,061.30
MX$848.33
List Price:  MX$1,187.73
You save:  MX$339.40
QR182.01
List Price:  QR254.83
You save:  QR72.82
P679.12
List Price:  P950.82
You save:  P271.70
KSh6,605.16
List Price:  KSh9,247.76
You save:  KSh2,642.59
E£2,394.23
List Price:  E£3,352.12
You save:  E£957.88
ብር2,861.57
List Price:  ብር4,006.43
You save:  ብር1,144.85
Kz41,791.64
List Price:  Kz58,511.64
You save:  Kz16,720
CLP$47,104.79
List Price:  CLP$65,950.47
You save:  CLP$18,845.68
CN¥361.79
List Price:  CN¥506.53
You save:  CN¥144.74
RD$2,896.80
List Price:  RD$4,055.76
You save:  RD$1,158.95
DA6,728.30
List Price:  DA9,420.16
You save:  DA2,691.86
FJ$112.64
List Price:  FJ$157.70
You save:  FJ$45.06
Q387.49
List Price:  Q542.52
You save:  Q155.02
GY$10,429.06
List Price:  GY$14,601.52
You save:  GY$4,172.46
ISK kr6,980.60
List Price:  ISK kr9,773.40
You save:  ISK kr2,792.80
DH502.81
List Price:  DH703.98
You save:  DH201.16
L883.05
List Price:  L1,236.34
You save:  L353.29
ден2,855.74
List Price:  ден3,998.26
You save:  ден1,142.52
MOP$401.24
List Price:  MOP$561.77
You save:  MOP$160.53
N$922.79
List Price:  N$1,291.99
You save:  N$369.19
C$1,835.15
List Price:  C$2,569.36
You save:  C$734.20
रु6,656.11
List Price:  रु9,319.09
You save:  रु2,662.97
S/186.09
List Price:  S/260.54
You save:  S/74.45
K192.70
List Price:  K269.79
You save:  K77.09
SAR187.48
List Price:  SAR262.50
You save:  SAR75.01
ZK1,344.69
List Price:  ZK1,882.68
You save:  ZK537.98
L230.99
List Price:  L323.40
You save:  L92.41
Kč1,163.34
List Price:  Kč1,628.77
You save:  Kč465.43
Ft18,094.88
List Price:  Ft25,334.28
You save:  Ft7,239.40
SEK kr539.27
List Price:  SEK kr755.02
You save:  SEK kr215.75
ARS$43,903.33
List Price:  ARS$61,468.17
You save:  ARS$17,564.84
Bs345.22
List Price:  Bs483.33
You save:  Bs138.11
COP$194,164.52
List Price:  COP$271,845.87
You save:  COP$77,681.34
₡25,478.72
List Price:  ₡35,672.25
You save:  ₡10,193.53
L1,231.47
List Price:  L1,724.16
You save:  L492.69
₲373,200.63
List Price:  ₲522,510.75
You save:  ₲149,310.11
$U1,910.59
List Price:  $U2,674.97
You save:  $U764.38
zł200.97
List Price:  zł281.37
You save:  zł80.40
Already have an account? Log In

Transcript

Hello friends, welcome to the next lab. In this lab, we will learn how to create a POST request request and then okay till we learn how to create a get request and we use the Entity Framework for getting the data. Now, we have to insert data into the database. So we have created one repository and in that repository, we have to add one method to insert data into the table. Now here, I will add one method return type of method is void student is the method and we pass the student object entities dot entities to learn an object of that class Okay. Now, I am implement that method because if a class, so here it gives an error.

So I need to implement now here maybe implement that method. So, how am I going to do that? Simply by using our object we add to that okay This method add that student object in our forum, but not in the database. So we'll have to add that student into the database for that, we have to create another one method which is sale method and this method will return a Boolean. Now, for this method, we need to implement that sale method. Okay?

We need to implement that sale method. So, here, again, I go into student repository class and implement the interface we can see your results soon with no return. Seal changes is the method and here the seal changes, method returns, how many records are updated change whatever, it return the count. Okay. Now POST method to over control in this post method we have to use HTTP okay. Now, the POST method requires the opposite of student use.

And now, I have to call that method in our repository. But before that, we need to check if that student is no or No. No here, we have to use that method. And often we hope to add that student in the Netherlands so are they We have clicked on sale method. Okay? If it returns true, we return okay response okay.

It's not the return status code 500 internal server. Now remember this team we use POST method and POST method get parameter from the body. Now we hope to add here From body then this POST method on it's completed now I have to run this application. Now it started running ugly. Oh, we'll call that post. So, I had a debugger here and you were really is the right copy that and paste it here.

Now our request is a post. So, check here both the controller these motion is hanging over Explain no copy that name. And so we pass decent data. So I use content and Content API application JSON we pass that parameter in the body. So here I require Jason. We have created the entity class, entity class.

In here, the ID is auto generated. So we no need to pass that Id okay? No need to check that. Yes. I use name directly. I do what I do in here.

I use mocks Okay, now, you see our database Damon's even cheap Table Okay, now you can see who the courts are present. Now I have to call into the send button our debugger each trigger, we can see here we have it to mark Condon name is Ivan that code and we can check, we get 200 response means the data is inserted. Oh, check that table now you can see You have successfully inserted one record in the table by using Entity Framework. Okay. Now we'll add one myth, which is put means to update the record. So I need to add that method in our interface.

So return to me the same boy. Student, same student as parameter. Now, I need to implement that in our repository class. So, here first I get student okay because I hope you get the student he exists in our table then and then only we can update that record. So, for getting student we write one method and here we pass it now each student is not known or not known. Then what we have to do?

We have to assign the values for students object okay students Id is equal in the student. I know I copy that two times because I change the name Same here. Change it to me after that for months now I have to update I use a bit No, we didn't Oh good. So I want to add you hear And put in here I changed it Okay. Now, here I have all of the students and the remaining said okay first what our table countries they will run in service three records Okay. Now either this application is running and after that I add debugger here and here, I need to change this port.

But remember, for identifying record we need ID. Okay, we need ID and the ID I feel our IDs three i think is right. Now we have to update that record. So I changed you XYZ and monster 400 Okay. Now, send that request. request comes, you know, we can check you.

Okay, we get the data now is what we get here. Cheap wonder, okay, what we need to confirm that with our database. So I go here and I refresh it and you can see here at third ID we change the name And maths. So our API works perfectly. Now we have to add last chord which is delete. So, how am I going to do that?

So for delete a youth we believe students okay? No, okay. We have to implement that input method or context class. Okay. So the repository class. This is up we'll see if we copy out.

From here. We paste it here. Because here we check if the student is present or not. If it is present, we remove that student Oh, we can see how I want to do that. He's use the method each method see what the student got Okay. Is that okay?

Now, we have to add that code to control what? Oh delete method require only the ID Okay. So, the move here showing you some more details, these students Something is wrong. Here, we change them and change these into power the power problem arises because we copy pasted code from our to them for timing I use this No I have to do this on only this is required. Mood controller. code is written here.

Debugger here again, I ran the application notes learning Okay. Now we have to go here and change our request to delete or delete We need to pass the ID we use last created ID three okay and check it again is our code is right or wrong which look right I could send the request okay. And why so? I have checked that it is not alone. Okay. Ds dP dT dt SR Because he or she seeing here these curly braces okay and again check is that working or not?

Please Mr. Peroni? No. Okay. Well the same thing with okay now comes here. The curly brace is remaining, or I'm not putting it here. So that's why it should not be This method now let's check you want it the data is received several times okay present now then that application and we wonder is no chick with that table oh you can see you third record is gone now we successfully implemented get put, post and delete so I intentionally not getting to add the subject into the database.

So you need to perform that task by yourself and if you Not able do that. So I will add next lecture to this our session where our tutorials for now. Thank you for watching have a nice day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.