MVC Questions

Types of action filters:

  • output cache
  • Handle error
  • Authorize

123456

System.componentmodel.dataannotation

 

Updatemodel:

Employee ob=new Employee();

updateModel(ob);

 

Tryupdatemodel

Formcollection

[bind] classname obname

 

[httppost(routeName)]

 

Modelstate.isvalid

 

When you an HTML helper, such as LabelFor() or TextBoxFor(), it displays a model property in a fixed manner. For example, LabelFor() renders a model property name in a <label> tag and TextBoxFor() renders a textbox in which a model property is shown for editing. Although this arrangement works fine in many cases, at times you need more control over the way data is shown to the end user. Consider, for example, that you have a model property that represents currency. While displaying this property value to the end user, you want to show a currency symbol such as $ along with the property value. Such a customization is not possible with the above-mentioned HTML helpers. Another example could be a DateTime model property that needs to be displayed in a specific custom format.

  • DisplayFor()
  • DisplayForModel()
  • EditorFor()
  • EditorForModel()

Updatemodel with include and exclude properties

@html.textbox(“id”,”value”,new{

Style=”bg-color:red;…”

Or

@class=”redtextbox”,@readonly=”true”

})

Editor template name is same as model name

Display

Displayformat

Scaffoldingcolomun(false/true)

 

@html.displaymodelfor

Sharedàdisplay temaplatesàurl

[UiHint(“to give other displaytemplate name”)]

Displayformodel

Editformodel

Automatically take the model and build the view…………

MvcBuildViews-àto enable compile time error checking

 

validateInput

@html.raw-àwill take html tags and render it and display appropriately

 

Standard

test

-Java script:

  • Procedural oriented programming language
  • There is no class objects all code are writing in one place
  • Lot of code and conflicts
  • No compilation of code checking
  • Time taken process and no proper productivity and difficult to manage the huge applications

Typescript:

  • Will fallows oops features
  • Code can be clearly modularized
  • TS=JS+extra features[oops]+ES6[modren javascript]
  • installation of typescript
    1. Typescript compiler
    2. npm install typescript
  • compilation
    1. tsc test.ts[tsc   typescript compiler]
    2. this compiler will convert from typescript to javascript
  • excecution
    1. node test.js
  • check which version on typescript installed
    1. tsc -v

 

 

 

Standard

Typescript Basics

Keywords:

  1. let—block level scope in es6 they introduced
  2. var—function level scope and it will be accessed very closest function
  3. const—to const creations
  4. enum–group of constants

when var is there why let came?

to reduce the conflicts  we are using this let and name duplicacy…

and when u changed the value outside it becomes coflict

 

conditional statements: if, ifelse, ternery

loops:

  • foreach—visit and process the element and retrun nothing and performs some …… function there u can write logic on the item

 

  • map—visit and process the element and return the array

 

  • for…in—no separate function here 

 

  • include—>to check the particular value that is available in an array nt …will check with the help of include

 

  • reduce: it will always take previous result…..reduce.png
  • If u want to match the current value with previous value we need to use reduce…

    Accumulator-àis the result of last value

    Current valueàis the current idex

    1st timeàaccumulatorà20

    And current index is: 30

 

  • indexof : to check the index of where variable is availble, and return index and if the value is not available it will return -1 always

 

Standard

Angular installation

  • node js
  • npm
  • angular cli
  1. with the help of node will execute angular applications
  2. once your install the node you will get npm
  3. in one centralized place all packages so communicate that place we need npm
  4. node packages or modules
  5. angular cli —web pack tool…this is also a node module, its used to build the project,create and build and deploy the project, it will compile and produce the bundled file and that bundle we can exceute by browser
  6. ng—angular cli
    1. npm install -g @angular/cli—>  -g global means node_modules of c drive will store
    2. to know the version and to test its installed properly or not
    3. ng –version
  7. to create the app
    1. ng new projectname
  8. run the project
    1. ng server
Standard

Angular 2 Training

1) what is the angular

  • Angular2 came in 2016
  • There is no class objects all code are writing in one place
  • All code is written in one place
  • Lot of code and conflicts
  • No customization of js code
  • Less conflicts and less issues are there
  • Time taken process and no proper productivity and difficult to manage the huge applications

Angular 2:

  • No similarity between angular js and angular…
  • Angular js we will write code again in javascript
  • Again same issues are coming
  • That’s why in angular2 code is coming  in Typesctipt
  • Angular invented by Google
  • TypeScript invented by Microsoft

what is typescript and what is javascript

  • even though you write code in typescript browser can understand in javascript…
  • so typescript will convert to javascript with compiler ???
  • with javascript we can write procedural based programming pop—-creating functions and all and oops features wont able to support by javascript
  • so typescript came into the market so we can write oops features in typescript
  • TS=JS+extra features[oops]+ES6[modren javascript]
  • installation of typescript
    • Typescript compiler
    • npm install typescript
  • compilation
    • tsc test.ts[tsc   typescript compiler]
    • this compiler will convert from typescript to javascript
  • excecution
    • node test.js
  • check which version on typescript installed
    • tsc -v

 

 

                    

 

Standard

my working node code

const express = require(‘express’);
const app=express();
var mongo = require(‘mongodb’);
app.use(express.json());
const coursesArray=[
{id:1,name:’course1′},
{id:2,name:’course2′},
{id:3,name:’course3′},
{id:4,name:’course4′},
{id:5,name:’course5′}
];
app.get(‘/api/courses/:id’,(req,res)=>{
console.log(req.param.id)
constcourse=coursesArray.find(c=>c.id===parseInt(req.params.id));
if(!course) res.status(404).send(“requested course id is not avilable”)
elseres.send(course)
});
app.post(‘/api/courses’,(req,res)=>{
varbody=req.body;
coursesArray.push(body);
res.send(coursesArray);
});
app.delete(‘/api/courses’,(req,res)=>{
varqueryParmId=req.query.id;
constcourse=coursesArray.find(c=>c.id===parseInt(req.query.id));
coursesArray.pop(course);
res.send(coursesArray);
});
app.listen(4000, ()=>console.log(“app listening 4000 port “))
Standard