static void Main(string[] args) { InitializeMapper(); //LinqToDB.Common.Configuration.Linq.AllowMultipleQuery = true; DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (s, s1) => Debug.WriteLine(s, s1); using (var db = new NorthwindDb()) { var q = (from o in db.OrderDetails .LoadWith(o => o.OrderDetailsOrder) .LoadWith(o => o.OrderDetailsOrder.Customer) .LoadWith(o => o.OrderDetailsOrder.Employee) where o.OrderDetailsOrder.Employee.LastName.StartsWith("King") select o) .ProjectTo <OrderDto>() .ToList(); foreach (var o in q) { Console.WriteLine( $"OrderDate: {o.OrderDetailsOrderOrderDate}\tOrderDetailsProductProductName:{o.OrderDetailsProductProductName}\tCustomerContactName: {o.OrderDetailsOrderCustomerContactName}\tQuantity: {o.Quantity}"); } } Console.ReadLine(); }
public ActionResult Products(int categoryId) { NorthwindDb db = new NorthwindDb(connectionString); IEnumerable <Product> products = db.GetProductsByCategoryId(categoryId); return(View(products)); }
public ActionResult Categories() { NorthwindDb db = new NorthwindDb(connectionString); IEnumerable <Category> categories = db.GetAll(); return(View(categories)); }
public ActionResult CustomerDetails(string customerId) { var db = new NorthwindDb(connectionString); Customer customer = db.GetCustomerById(customerId); return(View(customer)); }
public ActionResult Customers() { var db = new NorthwindDb(connectionString); var customers = db.GetCustomers(); return(View(customers)); }
public IActionResult OrderDetails(int year, string country) { NorthwindDb db = new NorthwindDb(_connectionString); List <Order> orders = db.GetOrdersForYear(year, country); return(View(orders)); }
public ActionResult Products() { NorthwindViewModel vm = new NorthwindViewModel(); NorthwindDb db = new NorthwindDb(_connectionString); vm.Products = db.GetProducts(); return(View(vm)); }
public IActionResult Products(int catId) { NorthwindDb db = new NorthwindDb(_connectionString); ProductsViewModel vm = new ProductsViewModel(); vm.Products = db.GetProductsForCategory(catId); vm.CategoryName = db.GetCategoryName(catId); return(View(vm)); }
public IActionResult Orders() { NorthwindDb db = new NorthwindDb(_connectionString); OrdersViewModel vm = new OrdersViewModel(); vm.Orders = db.GetOrders(); vm.CurrentDate = DateTime.Now; return(View(vm)); }
public IActionResult ShowSearchResults(string searchText) { NorthwindDb db = new NorthwindDb(_connectionString); SearchResultsViewModel vm = new SearchResultsViewModel(); vm.Products = db.Search(searchText); vm.SearchText = searchText; return(View(vm)); }
public ActionResult Categories() { NorthwindDb db = new NorthwindDb(_connectionString); CategoriesPageViewModel vm = new CategoriesPageViewModel { Categories = db.GetCategories() }; return(View(vm)); }
public ActionResult ShowProductSearchResults(string searchText) { NorthwindDb db = new NorthwindDb(_connectionString); ProductSearchViewModel vm = new ProductSearchViewModel { Products = db.SearchProducts(searchText), SearchText = searchText }; return(View(vm)); }
public ActionResult Index(string categoryName, int?minStock) { NorthwindDb db = new NorthwindDb(Properties.Settings.Default.ConStr); IEnumerable <Product> products = db.Search(categoryName, minStock); HomePageViewModel vm = new HomePageViewModel(); vm.Products = products; vm.CategoryName = categoryName; vm.MinUnitsInStock = minStock; return(View(vm)); }
public ActionResult Products(int catid) { NorthwindDb db = new NorthwindDb(connectionString); Category category = db.GetCategoryById(catid); IEnumerable <Product> products = db.GetProductsForCategory(catid); ProductsViewModel viewModel = new ProductsViewModel(); viewModel.Products = products; viewModel.Category = category; return(View(viewModel)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { await context.Response.WriteAsync(NorthwindDb.GetData()); }); }
public ActionResult Orders() { NorthwindDb db = new NorthwindDb(_connectionString); List <Order> orders = db.GetOrders(); OrdersPageViewModel viewModel = new OrdersPageViewModel { Orders = orders, Date = DateTime.Now }; return(View(viewModel)); }
static void Main(string[] args) { NorthwindDb db = new NorthwindDb(Properties.Settings.Default.ConStr); IEnumerable <Product> products = db.Search("Beverages", 50); products.ToList().ForEach(p => { Console.WriteLine($"{p.Name} - {p.CategoryName} - {p.UnitsInStock}"); }); Console.ReadKey(true); }
public IActionResult Index() { // Add to the service var path = hostingEnvironment.ContentRootPath; var folderPath = Path.Combine(path, "Database"); var filePath = Path.Combine(folderPath, "northwind.xml"); //var data = new[] { "Foo", "Bar" }; var data = NorthwindDb.GetRetiredEmployees(filePath); return(View("index", data)); }
public IActionResult SearchResults(int minStock, int maxStock) { NorthwindDb db = new NorthwindDb(@"Data Source=.\sqlexpress;Initial Catalog=Northwnd;Integrated Security=True;"); List <Product> products = db.SearchProducts(minStock, maxStock); SearchProductsViewModel vm = new SearchProductsViewModel { Products = products, MinStock = minStock, MaxStock = maxStock }; return(View(vm)); }
public ActionResult SearchResults(int min, int max) { NorthwindDb db = new NorthwindDb(_connectionString); List <Product> products = db.Search(min, max); SearchResultsViewModel vm = new SearchResultsViewModel { Products = products, Min = min, Max = max }; return(View(vm)); }
public void SimpleQuery() { using (var db = new NorthwindDb()) { var q = from c in db.Categories select c; foreach (var c in q) { Debug.WriteLine(c.CategoryName); } } }
public async Task <ActionResult> Report(Period period) { if (period.End == new DateTime()) { period.End = DateTime.Now; } else { period.End = period.End.AddSeconds(86399); } IEnumerable <OrderDetail> list; using (NorthwindDb db = new NorthwindDb()) { list = await db.OrderDetails .Include(o => o.Order) .Where(o => o.Order.OrderDate >= period.Start) .Where(o => o.Order.OrderDate <= period.End) .Include(o => o.Product).ToListAsync(); } var report = new List <Report>(); foreach (var order in list) { report.Add(new Report { Number = order.Order.ID, OrderDate = order.Order.OrderDate, Article = order.Product.ID, Name = order.Product.Name, Quantity = order.Quantity, UnitPrice = order.UnitPrice, Cost = order.Quantity * order.UnitPrice }); } CreatingExcelDoc.CreateDoc(report, period); ViewBag.Period = period; return(View("Report", report)); }
public CategoriesRepository(NorthwindDb db) : base(db) { }
public NorthwindRepository(NorthwindDb db) { Db = db; DbSet = db.Set <TEntity>(); }
public CustomersService(NorthwindDb db) { _db = db; }
public ImagesService(NorthwindDb db) { _db = db; }
public ProductsService(NorthwindDb db) { _db = db; }
//public ReportsController(NorthwindDb db) //{ // this.db = db; //} public ReportsController(NorthwindDb db) => this.db = db;
public IActionResult Categories() { NorthwindDb db = new NorthwindDb(_connectionString); return(View(db.GetCategories())); }
public OrdersService(NorthwindDb db) { _db = db; }