Telerik School Academy ASP.NET MVC.

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Telerik Software Academy Telerik School Academy.
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
C# Fundamentals – Part I
Welcome to the JSON-stores world Telerik Software Academy Databases.
NoSQL Concepts, Redis, MongoDB, CouchDB
Telerik Software Academy Telerik School Academy Creating E/R Diagrams with SQL Server.
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Processing Matrices and Multidimensional Tables Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Telerik Software Academy ASP.NET Web Forms.
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer
Telerik Software Academy End-to-end JavaScript Applications.
General and reusable solutions to common problems in software design Vasil Dininski Telerik Software Academy academy.telerik.com Intern at Telerik Academy.
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
ORM Concepts, Entity Framework (EF), DbContext
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
The past, the present, the future Learning & Development Team Telerik Software Academy.
Learn to Design Error Steady Code Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Working with Data Model Binders, Display Templates, Editor Templates, Validation… SoftUni Team Technical Trainers Software University
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
ASP.NET Web API Telerik Software Academy
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Inheritance, Abstraction, Encapsulation, Polymorphism Telerik Software Academy Mobile apps for iPhone & iPad.
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Presentation transcript:

Telerik School Academy ASP.NET MVC

 Scaffolding  Model Binders  Editor & Display Templates  Data Validation  Annotation attributes  Session, TempData and Cache 2

 Code generation framework for ASP.NET  When you want to quickly add boilerplate code that interacts with data models  Developer productivity enhancer  Can reduce the amount of time to develop standard data operations in your project  Enables customization  Provides an extensibility mechanism to customize generated code  VS 2013 includes pre-installed code generators for MVC, and Web API 4

Create CRUD pages with read/write actions, using Entity Framework

 To make easy of handling HTTP post request  Help the populating the parameters in action methods 7 DefaultModelBinder

 Parameter binding  The name attribute of the input HTML element should be the same as the name of pararameter in the action 8

 Object binding  Model binder will try to "construct" the object based on the name attributes on the input HTML elements 9

 Nested Objects binding  Use name attributes as following "{obj}.{nestedObj}" or use EditorFor 10

 Collection of primitive types binding  Use the same name attribute on every input element and the parameter name of the collection in the action (you can use loops) 11

 Collection of objects binding  Use name attributes like "[{index}].{property}" or use EditorFor in a for loop 12

 Collection of files binding  Use the same name attribute on all input type files as the name of the collection 13

14

 ASP.NET MVC comes with helpers methods  DisplayFor(), DisplayForModel()  EditorFor(), EditorForModel()  There are default implementation  Easily to be configured  Create folders "DisplayTemplates" and "EditorTemplates" the "Shared" folder or in the "Views/{Controller}" folder 16

 In the two new folders create a view for each type you want  string -> String.cshtml  int -> Int32.cshtml  DateTime -> DateTime.cshtml  Student -> Student.cshtml  The name of the files must reflect the data types and in them 17

 These views are normal view files  The framework will start using them instead of the default implementations  For example in the String.cshtml  Now all strings will be in paragraph element and will have quotes surrounding them  DisplayFor, EditorFor -> for properties  DisplayForModel, EditorForModel -> for model 18

 Passing additional information to the templates  There is an object "additionalViewData" in the helper methods as parameter  You can pass anything there as anonymous type  And get the values from the ViewData/ViewBag 19

 Sometimes you need two templates for one data type  Create the template with custom name  Decorate the property in the model with the UIHint attribute specifying the template name  You can set the name in the helpers too 20

 Attributes defined in System.ComponentModel.DataAnnotations  Covers common validation patterns  Required  StringLength  Regex  Range 22

23 AttributeDescription CompareChecks whether two specified properties in the model have the same value. CustomValidationChecks the value against the specified custom function. EnumDataTypeChecks whether the value can be matched to any of the values in the specified enumerated type. RangeChecks whether the value falls in the specified range. It defaults to numbers, but it can be configured to consider a range of dates, too. RegularExpressionChecks whether the value matches the specified expression. RemoteMakes an Ajax call to the server, and checks whether the value is acceptable. RequiredChecks whether a non-null value is assigned to the property. It can be configured to fail if an empty string is assigned. StringLengthChecks whether the string is longer than the specified value.

 ModelState.IsValid – will give us information about the data validation success  ModelState.AddModelError – custom error 24

– output errors – outputs validation message for specified property 25 Text box with integrated client-side validation jQuery validation library required for unobtrusive JavaScript validation

 Custom attributes  Inherit ValidationAttribute 26

 Your model should implemented IValidatableObject  From now on, MVC (works with EF too) will validate the object by your custom rules 27

29 AttributeDescription DisplayColumnSpecify the property of a model class for simple text display. HiddenInputRender value in a hidden input (when editing). UIHintSpecify the name of the template to use for rendering. DataTypeCommon templates ( , password, URL, currency) ReadOnlySpecify a read-only property (for model binding). DisplayFormatFormat strings and null display text ScaffoldColumnTurn off display and edit capabilities DisplayNameFriendly name for labels BindTells the model binder which properties to include/exclude

 Each client has session id, which ASP.NET stores  You can use it to store information in the memory of the application 31

 TempData can be used like a dictionary  Each saved value lasts for the current and the next request  Perfect for redirects 32

 You can save global data into the Cache  It works like dictionary  It is not per client, but rather global 33

Repository pattern and Unit of Work pattern

 Separate business code from data access  Separation of concerns  Testability  Encapsulate data access  Increased level of abstraction  More classes, less duplicated code  Maintainability, Flexibility, Testability  Generic repositories  IRepository  IRepository 35

36 Business & Domain Logic SQL Database File Web Service Exchange Rates Repository Blog Posts Repository Settings Repository

 Track changes in persistent objects  Efficient data access  Manage concurrency problems  Manage transactions  Keep business logic free of data access code  Keep business logic free from tracking changes  Allow business logic to work with logical transactions 37

38

 You may want to use IoC for dependency inversion  Ninject is quite easy to do  Install Ninject.MVC5 from NuGet  In App_Data/NinjectWebCommon add your bindings in RegisterServices method 39

 You may want to use AutoMapper to map your database models to ViewModels for the web  Install AutoMapper from NuGet  Make mappings for the models  Use them in your LINQ queries  Check the documentation  

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

1. Create a simple ASP.NET MVC Twitter-like system using data validation, Entity Framework, repository pattern and unit of work pattern. Your system should:  Have users and administrators  List all tweets for specific user in his profile  List all tweets containing specific tag (#fail) and use 15 minutes caching for each tag  Have administration for the tweets using ASP.NET scaffolding (admins only)  * Have Kendo UI Grid-based administration for tweets (with paging, sorting, filtering, etv.) 42

 “C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com 43