Skip to content

Instantly share code, notes, and snippets.

@Mohsens22
Last active December 29, 2019 17:13
Show Gist options
  • Select an option

  • Save Mohsens22/f86f8e7871a55d54a1ac47739b5ad168 to your computer and use it in GitHub Desktop.

Select an option

Save Mohsens22/f86f8e7871a55d54a1ac47739b5ad168 to your computer and use it in GitHub Desktop.
Asp MVC 101, Shamsi pour
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
data source=.;initial catalog=myDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework
public class Context : DbContext
{
public Context() : base("conn")
{
}
//public DbSet<Item> Items { get; set; }
}
@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" />
}
@using (Html.BeginForm("Delete", "Chef", FormMethod.Post))
{
<input type="hidden" for="Id" name="Id" value="@Model.Id" />
<input type="submit" value="Delete Account" />
}
<dl>
<dt></dt>
<dd>
</dd>
</dl>
Enable-Migrations
Add-Migration
Update-Database
@Mohsens22
Copy link
Author

@Mohsens22
Copy link
Author

Mohsens22 commented Dec 29, 2019

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

@Mohsens22
Copy link
Author

مدل سازی رستوران و پروژه ی کراد در ام وی سی

@Mohsens22
Copy link
Author

Mohsens22 commented Dec 29, 2019

using (var context = new Context()) 
            {

            }

@Mohsens22
Copy link
Author

@Html.ActionLink("Esm", "Action", "Controller")

@Mohsens22
Copy link
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