23 Mayıs 2010 Pazar

MVC business layer

public void Save(EmployeeViewModel employeeViewModel)
{
var employee
= (from emp in dataContext.Employees
where emp.EmployeeID == employeeViewModel.EmployeeID
select emp).SingleOrDefault();


if (employee != null)
{

employee.Address
= employeeViewModel.Address;
employee.Salary
= employeeViewModel.Salary;
employee.Title
= employeeViewModel.Title;
}
dataContext.SubmitChanges();
}

public void Save(EmployeeViewModel employeeViewModel)
{

var employee
= (from emp in dataContext.Employees
where emp.EmployeeID == employeeViewModel.EmployeeID
select emp).SingleOrDefault();

if (employee != null)
{
ModelCopier.CopyModel(employeeViewModel, employee);
}
dataContext.SubmitChanges();

}


 



refer :http://weblogs.asp.net/rajbk/archive/2010/03/31/easy-way-to-update-models-in-your-asp-net-mvc-business-layer.aspx

Hiç yorum yok:

Yorum Gönder