Last active
December 29, 2019 17:13
-
-
Save Mohsens22/f86f8e7871a55d54a1ac47739b5ad168 to your computer and use it in GitHub Desktop.
Asp MVC 101, Shamsi pour
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
| 1 Basics: | |
| - They are general, but u can skip to episode 3 | |
| - Web, request and response (User side) | |
| - Url = protocol + address + Endpoint(resource), it should make sence. | |
| - Request = Url, verb, body(payload) and attributes | |
| - Google example ( Types, sends request, gets html and shows) | |
| - HTTP verbs, post vs get : Post has body, get doesn't. Body can get encrypted. Post is used for manipulating data. | |
| - Get with attributes, post with body | |
| - Web server, application server | |
| - Web, Getting request and deciding what to do. | |
| 2- What is MVC | |
| - MVC architecture | |
| - Basic hello world applications | |
| - Roatings | |
| - Working with views, adding views | |
| - Partial pages | |
| - Controller - View | |
| 3- Entity framework | |
| - What is an ORM | |
| - Why we need ORM | |
| - How does Entity Framework does work? | |
| - DB context, Entity, DBSet, Migration | |
| - Model (Logic, Entity) | |
| 4- CRUD project |
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
| data source=.;initial catalog=myDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework |
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
| public class Context : DbContext | |
| { | |
| public Context() : base("conn") | |
| { | |
| } | |
| //public DbSet<Item> Items { get; set; } | |
| } |
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
| @using (Html.BeginForm("Add", "Chef", FormMethod.Post)) | |
| { | |
| <p>Name:</p> | |
| <input type="text" id="Name" name="Name"> | |
| <br /> | |
| <p>Exp:</p> | |
| <input type="number" id="Exprience" name="Exprience"> | |
| <input type="submit" value="Add" /> | |
| } |
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
| @using (Html.BeginForm("Delete", "Chef", FormMethod.Post)) | |
| { | |
| <input type="hidden" for="Id" name="Id" value="@Model.Id" /> | |
| <input type="submit" value="Delete Account" /> | |
| } |
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
| <dl> | |
| <dt></dt> | |
| <dd> | |
| </dd> | |
| </dl> |
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
| Enable-Migrations | |
| Add-Migration | |
| Update-Database |
Author
Author
0-Define entities and make plan
00- Implement Entities of Model
000- make controllers
1- Install Entity framework :
Right click on project > Manage nuget packages > search "Entity Framework" > Install
2-Add context
3-Add connection string to context
4- Add dbset to context
5- Enable Migration, Make a migration, update database
Package manager console
6- Add business logic. using context, NewsHa.Add(), NewsHa.ToList()
7- Use logic in controller.
8- Make views
Author
مدل سازی رستوران و پروژه ی کراد در ام وی سی
Author
using (var context = new Context())
{
}
Author
@Html.ActionLink("Esm", "Action", "Controller")
Author
Chef
Id: int
Name : String
Experience : int (0-100)
Create:
GET /Chef/Add -> فرم
POST /Chef/Add
Read:
GET /Chef => لیست سرآشپز را بدهد
-> Chef - Index
Update:
GET /Chef/Update
POST /Chef/Update
Delete:
POST /Chef/Delete
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Postman:
https://www.getpostman.com/downloads/