Friday, February 17, 2017

Asynchronous Requests for CRUD operations in Asp.Net MVC

In this post I will show how to use Asynchronous Requests in Asp.Net MVC. To continue this POST lets go through
for better understanding. we will change the above Synchronous post. In this post we can do CRUD operations using Bootstrap Modal, display data using Jquery DataTables and printing, exporting using jquery DataTables buttons.

Output:

















According to Microsoft Asynchronous Requests means:
In web applications that sees a large number of concurrent requests at start-up or has a bursty load (where concurrency increases suddenly), making these web service calls asynchronous will increase the responsiveness of your application. An asynchronous request takes the same amount of time to process as a synchronous request. For example, if a request makes a web service call that requires two seconds to complete, the request takes two seconds whether it is performed synchronously or asynchronously. However, during an asynchronous call, a thread is not blocked from responding to other requests while it waits for the first request to complete. Therefore, asynchronous requests prevent request queuing and thread pool growth when there are many concurrent requests that invoke long-running operations.

Wednesday, February 1, 2017

Sunday, January 29, 2017

How to use AutoMapper

Here in this Post I will show How to use AutoMapper.
Before that what is the necessity to use AutoMapper, when we are using ViewModels in Asp.Net MVC we need to map each and every column individually.

Suppose take a table of Employee with multiple columns as shown.
(Table) Employee: ID, FirstName, LastName, Gender, Salary, DOJ and DeptID

(ViewModel) EmployeeVM:

public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Gender { get; set; }
public int Salary { get; set; }
public DateTime DOJ { get; set; }
public int DeptID { get; set; }

To Insert New Employee, we need to map (ViewModel) EmployeeVM and (Model) Employee as shown below.
  

public void ADDEmployee(EmployeeVM e)
{
 Employee emp = new Employee();
 emp.ID = e.ID;
 emp.FirstName = e.FirstName;
 emp.LastName = e.LastName;
 emp.Gender = e.Gender;
 emp.Salary = e.Salary;
 emp.DOJ = e.DOJ;

 ent.Employees.Add(emp);
 ent.SaveChanges();
}

Supplose the Employee table had more columns like 20+... We need to map them one by one. Instead of doing that manually we will use AutoMapper.
Now Lets see how to use it for the above Employee table and EmployeeVM (ViewModel).

CRUD operations using Bootstrap Modal in Asp.Net MVC

In this post I will show how to CRUD operations in Asp.Net MVC using Bootstrap Modal and display records using Jquery DataTables with Exporting and printing.

Previously I had shown how to....
MVC:
Output: