SlideShare a Scribd company logo
Azerbaijan Technical University
ASP.NET MVC, ANGULARJS CRUD USING WEB
API, EF WITH STORED PROCEDURE
Date : 2017/12/01
By : SYED SHANU
Email: syedshanumcain@gmail.com
 My Name is Syed Shanu
 From Madurai, Tamil Nadu, India
 Microsoft MVP
 Code Project MVP
 Csharp Corner MVP
 10+ years of Experience as Software Engineer
 Working as a Senior Software Engineer at Zemax Solution ,Seoul ,Korea
 Blogger | Author | Speaker
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
 Introduction to MVC
 Introduction to AngularJs
 Introduction to SQL Server
 Introduction to WEB API
 Entity Framework
 Simple CRUD web application using MVC,AngularJs,Web API ,EF and SQL Server
Database
Controller
Model
View
User
Data Binding
Providers
Validators
Directives
Controllers
Modules
Expressions
Services
Dependency
Injection
Filters
Scope
Factories
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<body>
<div ng-app="">
<p>Name: <input type="text" ng-model="name"></p>
<p ng-bind="name"></p>
</div>
</body>
</html>
<html ng-app="MyAngularModule" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://code.angularjs.org/1.2.2/angular.js"></script>
<script>
angular.module('MyAngularModule', [])
.controller('myAngularController', function (
$scope
) { });
</script>
</head>
<body ng-controller="myAngularController">
<table> <tbody ng-repeat="Numbers in [1, 2, 3, 4,5,6,7,8,9,10] ">
<tr>
<td> {{Numbers}} </td>
</tr>
</tbody>
</table>
<table>
<tbody ng-repeat="Names in ['Shanu','Afraz','Raja','Afreen','Mak','Albert'] ">
<tr>
<td> {{Names}} </td>
</tr>
</tbody>
</table>
</body>
<html ng-app="MyAngularModule" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://code.angularjs.org/1.2.2/angular.js"></script>
<script>
angular.module('MyAngularModule', [])
.controller('myAngularController', function (
$scope
) {
$scope.todayDate = new Date();
$scope.Names=[{name:'Shanu'}, {name:'Afraz'}, {name:'Afreen'},
{name:'Vijay'}, {name:'Mak'}, {name:'Raja'}]; });
</script>
</head>
<body ng-controller="myAngularController" >
Date : {{todayDate}}
<br/> Filter By Name : <input type="text" ng-model="myNameFilters">
<table border=1>
<td ng-click="predicate = 'name'; reverse=!reverse">
<b>Toy Code</b> </td> </tr>
<tbody ng-repeat="nme in Names | filter:myNameFilters |
orderBy:predicate:reverse">
<tr> <td> {{nme.name}} </td>
</tr> </tbody>
</table>
</body> </html>
<html ng-app="MyAngularModule" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <title></title>
<script src="http://code.angularjs.org/1.2.2/angular.js"></script>
<script>
angular.module('MyAngularModule', [])
.controller('myAngularController', function (
$scope ) { }); </script>
</head>
<body ng-controller="myAngularController" ng-init="Names = [{name:'Shanu'},
{name:'Afraz'}, {name:'Afreen'}, {name:'Vijay'},
{name:'Mak'}, {name:'Raja'}]">
Filter By NAme : <input type="text" ng-model="myNameFilters">
<table border=1>
<tr>
<td ng-click="predicate = 'name'; reverse=!reverse"> <b>Toy Code</b>
</td>
</tr>
<tbody ng-repeat="nme in Names | filter:myNameFilters |
orderBy:predicate:reverse">
<tr>
<td> {{nme.name}} </td>
</tr>
</tbody>
</table> </body> </html>
http://www.c-sharpcorner.com/UploadFile/asmabegam/basic-sql-queries-for-beginners/
DBMS
SoftwareDatabase
Work with Multiple Browsers like Chrome,
IE, Firefox, Safari and Opera
Database
API
Entity Framework
EDM
Application
ADO.NET
Database
Using
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Create Database and Table
 Create SQL Stored Procedure for performing CRUD operations
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Create MVC Web Application in Visual Studio 2015
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Create Entity framework in our MVC Application
 Create Web API Controller
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
public class studentsController : ApiController
{
studentDBEntities objapi = new studentDBEntities();
// to Search Student Details and display the result
[HttpGet]
public IEnumerable<USP_Student_Select_Result> Get(string StudentName, string StudentEmail)
{
if (StudentName == null)
StudentName = "";
if (StudentEmail == null)
StudentEmail = "";
return objapi.USP_Student_Select(StudentName, StudentEmail).AsEnumerable();
}
// To Insert new Student Details
[HttpGet]
public IEnumerable<string> insertStudent(string StudentName, string StudentEmail, string Phone, string Address)
{
return objapi.USP_Student_Insert(StudentName, StudentEmail, Phone, Address).AsEnumerable();
}
//to Update Student Details
[HttpGet]
public IEnumerable<string> updateStudent(int stdID,string StudentName, string StudentEmail, string Phone, string Address)
{
return objapi.USP_Student_Update(stdID,StudentName, StudentEmail, Phone, Address).AsEnumerable();
}
//to Update Student Details
[HttpGet]
public string deleteStudent(int stdID)
{
objapi.USP_Student_Delete(stdID);
objapi.SaveChanges();
return "deleted";
}
}
 Creating AngularJs
Controller
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Creating AngularJs
Controller
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Add Module first
Module as a container for the different
parts of your app – controllers, services,
filters, directives, etc
Most applications have a main method that
instantiates and wires together the different
parts of the application.
Angular apps don't have a main method.
Instead modules declaratively specify how
an application should be bootstrapped.
// <reference path="../angular.js" />
/// <reference path="../angular.min.js" />
/// <reference path="../angular-animate.js" />
/// <reference path="../angular-animate.min.js" />
var app;
(function () {
app = angular.module("RESTClientModule", ['ngAnimate']);
})();
 Creating AngularJs
Controller
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Add Controller
AngularJS applications are controlled by controllers.
The ng-controller directive defines the application controller.
A controller is a JavaScript Object, created by a standard
JavaScript object constructor.
app.controller("AngularJs_studentsController", function ($scope, $timeout, $ro
otScope, $window, $http) {
$scope.date = new Date();
$scope.MyName = "shanu";
$scope.stdName = "";
$scope.stdemail = "";
$scope.showStudentAdd = true;
$scope.addEditStudents = false;
$scope.StudentsList=true;
$scope.showItem = true;
//This variable will be used for Insert/Edit/Delete Students details.
$scope.StdIDs = 0;
$scope.stdNames = "";
$scope.stdEmails = "";
$scope.Phones = "";
$scope.Addresss = "";
 Student Search
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Angular CRUD Method
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
//to get all Student Details
selectStudentDetails($scope.stdName, $scope.stdemail);
function selectStudentDetails(StudentName, StudentEmail) {
$http.get('/api/students/', { params: { StudentName: StudentName, StudentEmail:
StudentEmail } }).success(function (data) {
$scope.Students = data;
$scope.showStudentAdd = true;
$scope.addEditStudents = false;
$scope.StudentsList = true;
$scope.showItem = true;
})
.error(function () { $scope.error = "An Error has occured while loading posts!"; }); }
//Search
$scope.searchStudentDetails = function () {
selectStudentDetails($scope.stdName, $scope.stdemail);
}
// New Student Add Details
$scope.showStudentDetails = function () {
cleardetails();
$scope.showStudentAdd = true;
$scope.addEditStudents = true;
$scope.StudentsList = true;
$scope.showItem = true; }
//Edit Student Details
$scope.studentEdit = function studentEdit(StudentID, Name, Email, Phone, Address) {
cleardetails();
$scope.StdIDs = StudentID;
$scope.stdNames = Name
$scope.stdEmails = Email;
$scope.Phones = Phone;
$scope.Addresss = Address;
$scope.showStudentAdd = true;
$scope.addEditStudents = true;
$scope.StudentsList = true;
$scope.showItem = true;
}
//Delete Dtudent Detail
$scope.studentDelete = function studentDelete(StudentID, Name) {
cleardetails();
$scope.StdIDs = StudentID;
var delConfirm = confirm("Are you sure you want to delete the Student " + Name + " ?");
if (delConfirm == true) {
$http.get('/api/students/deleteStudent/', { params: { stdID:
$scope.StdIDs } }).success(function (data) {
alert("Student Deleted Successfully!!");
cleardetails();
selectStudentDetails('', '');
})
.error(function () {
$scope.error = "An Error has occured while loading posts!";
});
}
}
 Add New Student
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Edit New Student
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
 Angular CRUD Method
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
//clear all the control values after insert and edit.
function cleardetails() {
$scope.StdIDs = 0;
$scope.stdNames = "";
$scope.stdEmails = "";
$scope.Phones = "";
$scope.Addresss = "";
}
//Form Validation
$scope.Message = "";
$scope.IsFormSubmitted = false;
$scope.IsFormValid = false;
$scope.$watch("f1.$valid", function (isValid) {
$scope.IsFormValid = isValid;
});
//Save Student
$scope.saveDetails = function () {
$scope.IsFormSubmitted = true;
if ($scope.IsFormValid) {
//if the Student ID=0 means its new Student insert here i will call the Web api insert
method
if ($scope.StdIDs == 0) {
$http.get('/api/students/insertStudent/', { params: { StudentName: $scope.stdNames,
StudentEmail: $scope.stdEmails, Phone: $scope.Phones, Address:
$scope.Addresss } }).success(function (data) {
$scope.StudentsInserted = data;
alert($scope.StudentsInserted);
cleardetails();
selectStudentDetails('', '');
})
.error(function () { $scope.error = "An Error has occured while loading posts!"; });
}
else { // to update to the student details
$http.get('/api/students/updateStudent/', { params: { stdID: $scope.StdIDs,
StudentName: $scope.stdNames, StudentEmail: $scope.stdEmails, Phone: $scope.Phones,
Address: $scope.Addresss } }).success(function (data) {
$scope.StudentsUpdated = data;
alert($scope.StudentsUpdated);
cleardetails();
selectStudentDetails('', '');
})
.error(function () {
$scope.error = "An Error has occured while loading posts!";
});
} }
else { $scope.Message = "All the fields are required.";
} }
 Delete Student Details
Note: Refer this website to get SQL Script
and study in depth to create this website
http://www.c-
sharpcorner.com/UploadFile/asmabegam/mvc-
angularjs-crud-using-web-api-2-with-stored-
procedure/
https://mvp.microsoft.com/en-us/PublicProfile/5001980?fullName=Syed%20%20Shanu
http://www.c-sharpcorner.com/members/syed-shanu
http://www.codeproject.com/Articles/syed-shanu
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
@syedshanu3
syedshanumcain@gmail.com
https://www.facebook.com/syed.shanu.9
http://www.c-sharpcorner.com/members/syed-shanu
Ad

Recommended

PPTX
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
PPTX
Angular on ASP.NET MVC 6
Noam Kfir
 
PPTX
Building great spa’s with angular js, asp.net mvc and webapi
Maurice De Beijer [MVP]
 
PPTX
AngularJS Scopes
Mohamed Elkhodary
 
PPTX
Single Page Application (SPA) using AngularJS
M R Rony
 
PDF
introduction to Vue.js 3
ArezooKmn
 
PDF
End to-End SPA Development Using ASP.NET and AngularJS
Gil Fink
 
PPTX
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Deepu S Nath
 
PPTX
Angular js tutorial slides
samhelman
 
PPTX
Introducing ASP.NET Core 2.0
Steven Smith
 
PDF
Angular js - 10 reasons to choose angularjs
Nir Kaufman
 
PDF
Single page applications
Diego Cardozo
 
PPTX
MVC 6 Introduction
Sudhakar Sharma
 
PPTX
Angular vs React: Building modern SharePoint interfaces with SPFx
Dimcho Tsanov
 
PPTX
Latest Javascript MVC & Front End Frameworks 2017
AmarInfotech
 
PDF
Deep dive into Vue.js
선협 이
 
PPTX
Introduction to AngularJS Framework
Raveendra R
 
PPTX
AngularJS is awesome
Eusebiu Schipor
 
PPTX
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Aaron Jacobson
 
PPTX
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
MarkupBox
 
PPTX
Angular js
Mindtree
 
PPTX
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
PPT
ASP .net MVC
Divya Sharma
 
PPTX
Introduction to Angular JS
Santhosh Kumar Srinivasan
 
PPTX
AngularJS One Day Workshop
Shyam Seshadri
 
PDF
Node PDX: Intro to Sails.js
Mike McNeil
 
PDF
From MEAN to the MERN Stack
Troy Miles
 
PPT
Top java script frameworks ppt
Omkarsoft Bangalore
 
PDF
Client Side MVC & Angular
Alexe Bogdan
 
PDF
Einführung in React
Sebastian Springer
 

More Related Content

What's hot (20)

PPTX
Angular js tutorial slides
samhelman
 
PPTX
Introducing ASP.NET Core 2.0
Steven Smith
 
PDF
Angular js - 10 reasons to choose angularjs
Nir Kaufman
 
PDF
Single page applications
Diego Cardozo
 
PPTX
MVC 6 Introduction
Sudhakar Sharma
 
PPTX
Angular vs React: Building modern SharePoint interfaces with SPFx
Dimcho Tsanov
 
PPTX
Latest Javascript MVC & Front End Frameworks 2017
AmarInfotech
 
PDF
Deep dive into Vue.js
선협 이
 
PPTX
Introduction to AngularJS Framework
Raveendra R
 
PPTX
AngularJS is awesome
Eusebiu Schipor
 
PPTX
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Aaron Jacobson
 
PPTX
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
MarkupBox
 
PPTX
Angular js
Mindtree
 
PPTX
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
PPT
ASP .net MVC
Divya Sharma
 
PPTX
Introduction to Angular JS
Santhosh Kumar Srinivasan
 
PPTX
AngularJS One Day Workshop
Shyam Seshadri
 
PDF
Node PDX: Intro to Sails.js
Mike McNeil
 
PDF
From MEAN to the MERN Stack
Troy Miles
 
PPT
Top java script frameworks ppt
Omkarsoft Bangalore
 
Angular js tutorial slides
samhelman
 
Introducing ASP.NET Core 2.0
Steven Smith
 
Angular js - 10 reasons to choose angularjs
Nir Kaufman
 
Single page applications
Diego Cardozo
 
MVC 6 Introduction
Sudhakar Sharma
 
Angular vs React: Building modern SharePoint interfaces with SPFx
Dimcho Tsanov
 
Latest Javascript MVC & Front End Frameworks 2017
AmarInfotech
 
Deep dive into Vue.js
선협 이
 
Introduction to AngularJS Framework
Raveendra R
 
AngularJS is awesome
Eusebiu Schipor
 
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Aaron Jacobson
 
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
MarkupBox
 
Angular js
Mindtree
 
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
ASP .net MVC
Divya Sharma
 
Introduction to Angular JS
Santhosh Kumar Srinivasan
 
AngularJS One Day Workshop
Shyam Seshadri
 
Node PDX: Intro to Sails.js
Mike McNeil
 
From MEAN to the MERN Stack
Troy Miles
 
Top java script frameworks ppt
Omkarsoft Bangalore
 

Viewers also liked (7)

PDF
Client Side MVC & Angular
Alexe Bogdan
 
PDF
Einführung in React
Sebastian Springer
 
PDF
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
PDF
PMP Chap 7 - Project Cost Management - Part 2
Anand Bobade
 
PDF
PMPProcessGroupTasks
Anand Bobade
 
PDF
PMBOK-5th ed: PMP- Flashcards Part1/5
Anand Bobade
 
PDF
PMP Chap 7 - Project Cost Management - Part 1
Anand Bobade
 
Client Side MVC & Angular
Alexe Bogdan
 
Einführung in React
Sebastian Springer
 
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
PMP Chap 7 - Project Cost Management - Part 2
Anand Bobade
 
PMPProcessGroupTasks
Anand Bobade
 
PMBOK-5th ed: PMP- Flashcards Part1/5
Anand Bobade
 
PMP Chap 7 - Project Cost Management - Part 1
Anand Bobade
 
Ad

Similar to ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University (20)

PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
PPTX
AgularJS basics- angular directives and controllers
jobinThomas54
 
PDF
Angular pres
Frank Linehan
 
PDF
243329387 angular-docs
Abhi166803
 
PDF
Introduction of angular js
Tamer Solieman
 
PPTX
Valentine with AngularJS
Vidyasagar Machupalli
 
PDF
Course CodeSchool - Shaping up with Angular.js
Vinícius de Moraes
 
PPTX
Angular Js Get Started - Complete Course
EPAM Systems
 
PPT
ASP.NET MVC Presentation
ivpol
 
PPTX
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Learnimtactics
 
PPTX
Top 10 Mistakes AngularJS Developers Make
Mark Meyer
 
PDF
Animation And Testing In AngularJS
Edureka!
 
PDF
Spring MVC Intro / Gore - Nov NHJUG
Ted Pennings
 
PDF
AngularJS Framework
Barcamp Saigon
 
PDF
AngularJS Framework
CloudVis Technology
 
PDF
AangularJS Framework
CloudVis Technology
 
PPT
Angular data binding by Soft Solutions4U
sharsen
 
PPTX
AngularJS Introduction, how to run Angular
SamuelJohnpeter
 
PPTX
AngularJS in 60ish Minutes
Dan Wahlin
 
PPTX
Intoduction to Angularjs
Gaurav Agrawal
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
AgularJS basics- angular directives and controllers
jobinThomas54
 
Angular pres
Frank Linehan
 
243329387 angular-docs
Abhi166803
 
Introduction of angular js
Tamer Solieman
 
Valentine with AngularJS
Vidyasagar Machupalli
 
Course CodeSchool - Shaping up with Angular.js
Vinícius de Moraes
 
Angular Js Get Started - Complete Course
EPAM Systems
 
ASP.NET MVC Presentation
ivpol
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Learnimtactics
 
Top 10 Mistakes AngularJS Developers Make
Mark Meyer
 
Animation And Testing In AngularJS
Edureka!
 
Spring MVC Intro / Gore - Nov NHJUG
Ted Pennings
 
AngularJS Framework
Barcamp Saigon
 
AngularJS Framework
CloudVis Technology
 
AangularJS Framework
CloudVis Technology
 
Angular data binding by Soft Solutions4U
sharsen
 
AngularJS Introduction, how to run Angular
SamuelJohnpeter
 
AngularJS in 60ish Minutes
Dan Wahlin
 
Intoduction to Angularjs
Gaurav Agrawal
 
Ad

Recently uploaded (20)

PDF
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
PPTX
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
PPTX
List View Components in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
PPTX
How to use search fetch method in Odoo 18
Celine George
 
PPTX
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
PPTX
Wage and Salary Computation.ppt.......,x
JosalitoPalacio
 
PPTX
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
PPTX
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PDF
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
PDF
Hurricane Helene Application Documents Checklists
Mebane Rash
 
PDF
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
 
PDF
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
PPTX
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
PPTX
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
List View Components in Odoo 18 - Odoo Slides
Celine George
 
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
How to use search fetch method in Odoo 18
Celine George
 
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Wage and Salary Computation.ppt.......,x
JosalitoPalacio
 
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
Hurricane Helene Application Documents Checklists
Mebane Rash
 
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
Photo chemistry Power Point Presentation
mprpgcwa2024
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 

ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University

  • 1. Azerbaijan Technical University ASP.NET MVC, ANGULARJS CRUD USING WEB API, EF WITH STORED PROCEDURE Date : 2017/12/01 By : SYED SHANU Email: [email protected]
  • 2.  My Name is Syed Shanu  From Madurai, Tamil Nadu, India  Microsoft MVP  Code Project MVP  Csharp Corner MVP  10+ years of Experience as Software Engineer  Working as a Senior Software Engineer at Zemax Solution ,Seoul ,Korea  Blogger | Author | Speaker
  • 4.  Introduction to MVC  Introduction to AngularJs  Introduction to SQL Server  Introduction to WEB API  Entity Framework  Simple CRUD web application using MVC,AngularJs,Web API ,EF and SQL Server
  • 7. <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script> <body> <div ng-app=""> <p>Name: <input type="text" ng-model="name"></p> <p ng-bind="name"></p> </div> </body> </html> <html ng-app="MyAngularModule" xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://code.angularjs.org/1.2.2/angular.js"></script> <script> angular.module('MyAngularModule', []) .controller('myAngularController', function ( $scope ) { }); </script> </head> <body ng-controller="myAngularController"> <table> <tbody ng-repeat="Numbers in [1, 2, 3, 4,5,6,7,8,9,10] "> <tr> <td> {{Numbers}} </td> </tr> </tbody> </table> <table> <tbody ng-repeat="Names in ['Shanu','Afraz','Raja','Afreen','Mak','Albert'] "> <tr> <td> {{Names}} </td> </tr> </tbody> </table> </body>
  • 8. <html ng-app="MyAngularModule" xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://code.angularjs.org/1.2.2/angular.js"></script> <script> angular.module('MyAngularModule', []) .controller('myAngularController', function ( $scope ) { $scope.todayDate = new Date(); $scope.Names=[{name:'Shanu'}, {name:'Afraz'}, {name:'Afreen'}, {name:'Vijay'}, {name:'Mak'}, {name:'Raja'}]; }); </script> </head> <body ng-controller="myAngularController" > Date : {{todayDate}} <br/> Filter By Name : <input type="text" ng-model="myNameFilters"> <table border=1> <td ng-click="predicate = 'name'; reverse=!reverse"> <b>Toy Code</b> </td> </tr> <tbody ng-repeat="nme in Names | filter:myNameFilters | orderBy:predicate:reverse"> <tr> <td> {{nme.name}} </td> </tr> </tbody> </table> </body> </html> <html ng-app="MyAngularModule" xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://code.angularjs.org/1.2.2/angular.js"></script> <script> angular.module('MyAngularModule', []) .controller('myAngularController', function ( $scope ) { }); </script> </head> <body ng-controller="myAngularController" ng-init="Names = [{name:'Shanu'}, {name:'Afraz'}, {name:'Afreen'}, {name:'Vijay'}, {name:'Mak'}, {name:'Raja'}]"> Filter By NAme : <input type="text" ng-model="myNameFilters"> <table border=1> <tr> <td ng-click="predicate = 'name'; reverse=!reverse"> <b>Toy Code</b> </td> </tr> <tbody ng-repeat="nme in Names | filter:myNameFilters | orderBy:predicate:reverse"> <tr> <td> {{nme.name}} </td> </tr> </tbody> </table> </body> </html>
  • 10. Work with Multiple Browsers like Chrome, IE, Firefox, Safari and Opera Database API
  • 12. Using Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/
  • 13.  Create Database and Table  Create SQL Stored Procedure for performing CRUD operations Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/
  • 14.  Create MVC Web Application in Visual Studio 2015 Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/
  • 15. Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/  Create Entity framework in our MVC Application
  • 16.  Create Web API Controller Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/ public class studentsController : ApiController { studentDBEntities objapi = new studentDBEntities(); // to Search Student Details and display the result [HttpGet] public IEnumerable<USP_Student_Select_Result> Get(string StudentName, string StudentEmail) { if (StudentName == null) StudentName = ""; if (StudentEmail == null) StudentEmail = ""; return objapi.USP_Student_Select(StudentName, StudentEmail).AsEnumerable(); } // To Insert new Student Details [HttpGet] public IEnumerable<string> insertStudent(string StudentName, string StudentEmail, string Phone, string Address) { return objapi.USP_Student_Insert(StudentName, StudentEmail, Phone, Address).AsEnumerable(); } //to Update Student Details [HttpGet] public IEnumerable<string> updateStudent(int stdID,string StudentName, string StudentEmail, string Phone, string Address) { return objapi.USP_Student_Update(stdID,StudentName, StudentEmail, Phone, Address).AsEnumerable(); } //to Update Student Details [HttpGet] public string deleteStudent(int stdID) { objapi.USP_Student_Delete(stdID); objapi.SaveChanges(); return "deleted"; } }
  • 17.  Creating AngularJs Controller Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/
  • 18.  Creating AngularJs Controller Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/  Add Module first Module as a container for the different parts of your app – controllers, services, filters, directives, etc Most applications have a main method that instantiates and wires together the different parts of the application. Angular apps don't have a main method. Instead modules declaratively specify how an application should be bootstrapped. // <reference path="../angular.js" /> /// <reference path="../angular.min.js" /> /// <reference path="../angular-animate.js" /> /// <reference path="../angular-animate.min.js" /> var app; (function () { app = angular.module("RESTClientModule", ['ngAnimate']); })();
  • 19.  Creating AngularJs Controller Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/  Add Controller AngularJS applications are controlled by controllers. The ng-controller directive defines the application controller. A controller is a JavaScript Object, created by a standard JavaScript object constructor. app.controller("AngularJs_studentsController", function ($scope, $timeout, $ro otScope, $window, $http) { $scope.date = new Date(); $scope.MyName = "shanu"; $scope.stdName = ""; $scope.stdemail = ""; $scope.showStudentAdd = true; $scope.addEditStudents = false; $scope.StudentsList=true; $scope.showItem = true; //This variable will be used for Insert/Edit/Delete Students details. $scope.StdIDs = 0; $scope.stdNames = ""; $scope.stdEmails = ""; $scope.Phones = ""; $scope.Addresss = "";
  • 20.  Student Search Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/
  • 21.  Angular CRUD Method Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/ //to get all Student Details selectStudentDetails($scope.stdName, $scope.stdemail); function selectStudentDetails(StudentName, StudentEmail) { $http.get('/api/students/', { params: { StudentName: StudentName, StudentEmail: StudentEmail } }).success(function (data) { $scope.Students = data; $scope.showStudentAdd = true; $scope.addEditStudents = false; $scope.StudentsList = true; $scope.showItem = true; }) .error(function () { $scope.error = "An Error has occured while loading posts!"; }); } //Search $scope.searchStudentDetails = function () { selectStudentDetails($scope.stdName, $scope.stdemail); } // New Student Add Details $scope.showStudentDetails = function () { cleardetails(); $scope.showStudentAdd = true; $scope.addEditStudents = true; $scope.StudentsList = true; $scope.showItem = true; } //Edit Student Details $scope.studentEdit = function studentEdit(StudentID, Name, Email, Phone, Address) { cleardetails(); $scope.StdIDs = StudentID; $scope.stdNames = Name $scope.stdEmails = Email; $scope.Phones = Phone; $scope.Addresss = Address; $scope.showStudentAdd = true; $scope.addEditStudents = true; $scope.StudentsList = true; $scope.showItem = true; } //Delete Dtudent Detail $scope.studentDelete = function studentDelete(StudentID, Name) { cleardetails(); $scope.StdIDs = StudentID; var delConfirm = confirm("Are you sure you want to delete the Student " + Name + " ?"); if (delConfirm == true) { $http.get('/api/students/deleteStudent/', { params: { stdID: $scope.StdIDs } }).success(function (data) { alert("Student Deleted Successfully!!"); cleardetails(); selectStudentDetails('', ''); }) .error(function () { $scope.error = "An Error has occured while loading posts!"; }); } }
  • 22.  Add New Student Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/
  • 23.  Edit New Student Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/
  • 24.  Angular CRUD Method Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/ //clear all the control values after insert and edit. function cleardetails() { $scope.StdIDs = 0; $scope.stdNames = ""; $scope.stdEmails = ""; $scope.Phones = ""; $scope.Addresss = ""; } //Form Validation $scope.Message = ""; $scope.IsFormSubmitted = false; $scope.IsFormValid = false; $scope.$watch("f1.$valid", function (isValid) { $scope.IsFormValid = isValid; }); //Save Student $scope.saveDetails = function () { $scope.IsFormSubmitted = true; if ($scope.IsFormValid) { //if the Student ID=0 means its new Student insert here i will call the Web api insert method if ($scope.StdIDs == 0) { $http.get('/api/students/insertStudent/', { params: { StudentName: $scope.stdNames, StudentEmail: $scope.stdEmails, Phone: $scope.Phones, Address: $scope.Addresss } }).success(function (data) { $scope.StudentsInserted = data; alert($scope.StudentsInserted); cleardetails(); selectStudentDetails('', ''); }) .error(function () { $scope.error = "An Error has occured while loading posts!"; }); } else { // to update to the student details $http.get('/api/students/updateStudent/', { params: { stdID: $scope.StdIDs, StudentName: $scope.stdNames, StudentEmail: $scope.stdEmails, Phone: $scope.Phones, Address: $scope.Addresss } }).success(function (data) { $scope.StudentsUpdated = data; alert($scope.StudentsUpdated); cleardetails(); selectStudentDetails('', ''); }) .error(function () { $scope.error = "An Error has occured while loading posts!"; }); } } else { $scope.Message = "All the fields are required."; } }
  • 25.  Delete Student Details Note: Refer this website to get SQL Script and study in depth to create this website http://www.c- sharpcorner.com/UploadFile/asmabegam/mvc- angularjs-crud-using-web-api-2-with-stored- procedure/