public ActionResult Pdf_Export_Read([DataSourceRequest]DataSourceRequest request) { using (var northwind = new SampleEntitiesDataContext()) { return Json(northwind.Employees.ToList().ToDataSourceResult(request, e => new EmployeeViewModel { EmployeeID = e.EmployeeID, Country = e.Country, Title = e.Title, FirstName = e.FirstName, LastName = e.LastName })); } }
private void PopulateCategories() { var dataContext = new SampleEntitiesDataContext(); var categories = dataContext.Categories .Select(c => new CategoryViewModel { CategoryID = c.CategoryID, CategoryName = c.CategoryName }) .OrderBy(e => e.CategoryName); ViewData["categories"] = categories; ViewData["defaultCategory"] = categories.First(); }
private static IEnumerable<EmployeeViewModel> GetEmployees() { var northwind = new SampleEntitiesDataContext(); return northwind.Employees.ToList().Select(employee => new EmployeeViewModel { EmployeeID = employee.EmployeeID, FirstName = employee.FirstName, LastName = employee.LastName, Country = employee.Country, City = employee.City, Notes = employee.Notes, Title = employee.Title, Address = employee.Address, HomePhone = employee.HomePhone }); }
private static IEnumerable<OrderViewModel> GetOrders() { var northwind = new SampleEntitiesDataContext(); return northwind.Orders.Select(order => new OrderViewModel { ContactName = order.Customer.ContactName, Freight = order.Freight, OrderDate = order.OrderDate, ShippedDate = order.ShippedDate, OrderID = order.OrderID, ShipAddress = order.ShipAddress, ShipCountry = order.ShipCountry, ShipName = order.ShipName, ShipCity = order.ShipCity, EmployeeID = order.EmployeeID, CustomerID = order.CustomerID }); }
private static IEnumerable<CustomerViewModel> GetCustomers() { var northwind = new SampleEntitiesDataContext(); return northwind.Customers.Select(customer => new CustomerViewModel { CustomerID = customer.CustomerID, CompanyName = customer.CompanyName, ContactName = customer.ContactName, ContactTitle = customer.ContactTitle, Address = customer.Address, City = customer.City, Region = customer.Region, PostalCode = customer.PostalCode, Country = customer.Country, Phone = customer.Phone, Fax = customer.Fax, Bool = customer.Bool }); }
public IEnumerable<ProductViewModel> GetProducts(string text) { var northwind = new SampleEntitiesDataContext(); var products = northwind.Products.Select(product => new ProductViewModel { ProductID = product.ProductID, ProductName = product.ProductName, UnitPrice = product.UnitPrice ?? 0, UnitsInStock = product.UnitsInStock ?? 0, UnitsOnOrder = product.UnitsOnOrder ?? 0, Discontinued = product.Discontinued }); if (!string.IsNullOrEmpty(text)) { products = products.Where(p => p.ProductName.Contains(text)); } return products; }
public ProductService(SampleEntitiesDataContext entities) { this.entities = entities; }
public ActionResult FilterMenuCustomization_Titles() { var db = new SampleEntitiesDataContext(); return Json(db.Employees.Select(e => e.Title).Distinct()); }