Build Data Driven Apps with ASP.NET Core Rachel Appel.

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Advertisements

Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Introduction to MVC Action Methods, Edit View, and a Search Feature NTPCUG Dr. Tom Perkins.
{ Model View Controller ASP.NET By Scott Crooks & Maggie Wettergreen.
Building Modern Websites with ASP.NET Rachel Appel
ASP MVC s/mvc-4/getting-started-with- aspnet-mvc4/intro-to-aspnet- mvc-4.
Introduction to Entity Framework Part 1 Tom Perkins NTPCUG.
06 | Implementing Web APIs Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
Direct Congress Dan Skorupski Dan Vingo. Inner workings Reminder: MVC design pattern Procedural view: From request to response o Request passed to a view.
What’s new in ASP.NET MVC 3 Building a NerdDinner/AppStore Application.
ASP.NET 4.0 Web Developers User Group Israel June 2009.
Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
Introduction to MVC Adding Model Classes NTPCUG Tom Perkins, Ph.D.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC - Models.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
CS 415 N-Tier Application Development By Umair Ashraf June 28,2013 National University of Computer and Emerging Sciences Lecture # 5 Microsoft MVC3 Architecture.
Introduction to Entity Framework Part 2 CRUD Scaffolding Tom Perkins NTPCUG.
Lap Around Visual Studio 2008 &.NET 3.5 Enhancements.
Enterprise.NET 1 CA - presentation HENDRI FRANYOHT082210N KRISHNAMURTHY SAMANTH YADAVHT082239L CAI XIANGHT082182A KHAING MYAT THWEHT082208L AUNG MOEHT082184B.
ASP.NET MVC Intro class MainContoller { function Index() {... raw data HTML CSS JavaScript REQUEST RESPONSE.
BIT 286: Web Applications Lecture 10 : Thursday, February 5, 2015 ASP.Net Form Submission.
Jeff King Senior Program Manager Microsoft Session Code: WIA204.
J. Michael Palermo IV Director of Development Interface, USA WUX203.
Getting Started with ASP.NET MVC BRIJ BHUSHAN MISHRA.
Enterprise.NET 1 CA - presentation HENDRI FRANYOHT082210N KRISHNAMURTHY SAMANTH YADAVHT082239L CAI XIANGHT082182A KHAING MYAT THWEHT082208L AUNG MOEHT082184B.
Getting started with ASP.NET MVC Dhananjay
Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.
Microsoft /web ® Building Web Apps with ASP.NET Jump Start Scott Hanselman Jon Galloway.
06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
ASP.NET MVC Telerik Academy
Working with Data Model Binders, Display Templates, Editor Templates, Validation… SoftUni Team Technical Trainers Software University
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
Jean-Claude Trachsel Senior Consultant, Trivadis AG The good news.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
Bob German Principal Architect Developing SharePoint Applications with MVC and Entity Framework.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
AngularJS and SharePoint
1 Using MVC 6. MVC vs. ASP Web Forms Both run under ASP.NET Can coexist In Web Forms, browser requests page. xxx.aspx and xxx.aspx.cs on the server Page.
Improving Your Application with IntelliTrace #ITDevConnections.
Developers Introduction to the Power BI Platform.
Jim Fawcett CSE686 – Internet Programming Summer 2010
Xamarin Development with
Jim Fawcett CSE686 – Internet Programming Spring 2014
Getting Started with MVC 5 and Visual Studio 2013
Introduction to .NET Florin Olariu
An introduction to ASP.Net with MVC Nischal S
Building production ready APIs with ASP.NET Core 2.0
Building Web Applications with Microsoft ASP
Microsoft Active Directory Certificate Services and System Center Configuration Manager Internet Based Client Management.
Entity Framework DB From Code, OOP Introduction
Jim Fawcett CSE686 – Internet Programming Spring 2012
Social Media And Global Computing Introduction to The MVC Pattern
MVC Architecture, Symfony Framework for PHP Web Apps
Migrating SharePoint Add-ins from Azure ACS to Azure AD
C#: ASP.NET MVC Overview
Office 365 Development July 2014.
Play Framework: Introduction
CMPE 280 Web UI Design and Development October 24 Class Meeting
PHP Training at GoLogica in Bangalore
04 | Customizing Controllers
Data Structures and Database Applications Custom Models with MVC
Controllers.
Social Media And Global Computing Managing MVC with Custom Models
IT College 2016, Andres käver
ASP.NET MVC Web Development
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Build Data Driven Apps with ASP.NET Core Rachel Appel

Agenda Overview of ASP.NET MVC Models Controllers Routing & REST Views ViewModels

ASP.NET MVC Models Views Controllers ViewModels

ASP.NET MVC Overview ASP.NET implementation of MVC MVC Pattern What about other patterns? MVVM Pattern, MVW, or MV* Patterns Routing RESTful

Models The application’s data Expressed in code as classes and their members Contains relationships Mapped to database objects

Models namespace Bakery.Models { public class Category { [Key] public int Id { get; set; } public string Name { get; set; } public virtual ICollection Products { get; set; } }

Models namespace Bakery.Models { public class Product { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public string Image { get; set; } public decimal Price { get; set; } public DateTime ExpirationDate { get; set; } public int QuantityOnHand { get; set; } }

Entity Framework Code First Database First Model First DbSet Database Initializer (Code first) DBContext

Entity Framework public class BakeryContext : DbContext { public DbSet CartItem { get; set; } public DbSet Order { get; set; } public DbSet OrderDetails { get; set; } public DbSet ShoppingCart { get; set; } public DbSet Category { get; set; } public DbSet Products { get; set; } }

Entity Framework System.Data.Entity.Database.SetInitializer( new Models.DBContextInitializer()); In the global.asax.cs file

Entity Framework public class DBContextInitializer : DropCreateDatabaseAlways { protected override void Seed(MyContext context) { // fill db }

Controllers Match.com for Models and Views Traffic Cop Perform routing Accepts HTTP requests Front door of application Security

Controllers namespace Bakery.Controllers { public class ProductsController : Controller { private BakeryContext db = new BakeryContext(); public ActionResult Index() { return View(db.Products.ToList()); }

Controllers HTTP POST Data & HTTP Verbs [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit(Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(product); }

Model Binding Matches model properties with HTTP Form values Default Model Binder Custom Model Binder Compound fields Calculated fields Dynamically created fields Fields that don’t map nicely to model

Routing / RESTful URLs REST : Representational State Transfer Request resources via RESTful URL

URLS Not RESTful RESTful

/products/ /products/details/cupcake /products/create /products/edit /products/delete/cupcake public class ProductsController : Controller { public ActionResult Index() {...} public ActionResult Details(string? name) {...} public ActionResult Create() {...} [HttpPost] public ActionResult Create(Product product) {} public ActionResult Edit(string? name) {...} [HttpPost] public ActionResult Edit(Product product) {...} public ActionResult Delete(string? name) {...} }

Routing public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }); }

Routing protected void Application_Start() { RouteConfig.RegisterRoutes(RouteTable.Routes); }

Views The UI/Presentation layer Renders a model or ViewModel Does not contain business logic A visualization of data Expects data from one source: a model or ViewModel Use HTML Helpers or custom HTML

Views Helpers Links Controls

Convention over Configuration Controller and action method name Matches the URL

(var item in Model) => => => => "Edit", new { id=item.Id }) "Details", new { id=item.Id }) "Delete", new { id=item.Id }) }

Views and JavaScript Libraries Included in some VS Project Template You can use any 3 rd party JS library in MVC views jQuery & jQuery Mobile Bootstrap Modernizr Respond.js Angular

Views Validation Model attributes

Scaffolding Quickly create controllers and views based on models Great for prototyping Great for UI base

ViewModels A representation of one or more models Formatted & polished data UI logic code to format data One single ViewModel object per view Promotes SOC (Separation of Concerns)

ViewModels public class CustomerViewModel { public Customer Customer { get; set; } public StatesDictionary States { get; set; } public CustomerViewModel(Customer customer) { Customer = customer; States = new StatesDictionary(); }

Sumary Models, Views, Controllers Routing, Security, Deployment, OWIN

Rate This Session Now! Rate with Mobile App: Select the session from the Agenda or Speakers menus Select the Actions tab Click Rate Session Rate with Website: Register at Go to Select this session from the list and rate it Tell Us What You Thought of This Session Be Entered to WIN Prizes! #ITDevConnections