public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request) { using (var northwind = new NorthwindEntities()) { return Json(northwind.Products.ToDataSourceResult(request, p => new { p.ProductID, p.ProductName, p.QuantityPerUnit, p.UnitPrice, p.UnitsInStock })); } }
public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request) { using (var northwind = new NorthwindEntities()) { return Json(northwind.Orders.ToDataSourceResult(request, o => new { o.OrderID, o.Freight, o.OrderDate, o.ShipName, o.ShipCity })); } }
public ActionResult Employees([DataSourceRequest] DataSourceRequest request) { using (var northwind = new NorthwindEntities()) { return Json(northwind.Employees.ToDataSourceResult(request, e => new EmployeeViewModel { EmployeeID = e.EmployeeID, FirstName = e.FirstName, LastName = e.LastName, Country = e.Country, City = e.City, Title = e.Title })); } }
public ActionResult Orders(int employeeID, [DataSourceRequest] DataSourceRequest request) { using (var northwind = new NorthwindEntities()) { return Json(northwind.Orders .Where(order => order.EmployeeID == employeeID) .ToDataSourceResult(request, o => new OrderViewModel { OrderID = o.OrderID, ShipCountry = o.ShipCountry, ShipAddress = o.ShipAddress, ShipName = o.ShipName }) ); } }
public ActionResult Orders([DataSourceRequest] DataSourceRequest request, int? employeeID) { using (var northwind = new NorthwindEntities()) { IQueryable<Order> Orders = northwind.Orders; if (employeeID != null) { Orders = Orders.Where(order => order.EmployeeID == employeeID); } return Json(Orders.ToDataSourceResult(request, o => new OrderViewModel { EmployeeID = o.EmployeeID, OrderID = o.OrderID, ShipCountry = o.ShipCountry, ShipAddress = o.ShipAddress, ShipName = o.ShipName }) ); } }
public ProductController() { db = new NorthwindEntities(); }
public static ProductViewModel GetProduct(this NorthwindEntities db, int id) { return(db.GetProducts().FirstOrDefault(x => x.ProductID == id)); }