public async System.Threading.Tasks.Task <ActionResult> Products() { _northwindRepository = new NorthwindRepository(); var list = await _northwindRepository.GetProductList(); return(View(list.Data)); }
public async System.Threading.Tasks.Task <ActionResult> OffShelf(int ProductID) { _northwindRepository = new NorthwindRepository(); var result = await _northwindRepository.OffShelf(ProductID); //可考慮回傳訊息:新增成功、失敗,原因。 return(RedirectToAction("Products", "Home")); }
public async System.Threading.Tasks.Task <ActionResult> EditPrice(ProductsModel Product) { _northwindRepository = new NorthwindRepository(); var result = await _northwindRepository.UpdatePrice(Product.ProductID, Product.UnitPrice); //可考慮回傳訊息:新增成功、失敗,原因。 return(RedirectToAction("Products", "Home")); }
public void ExecuteReaderWithPagingByPersister(int pageIndex, int pageSize) { var persister = new TrimReaderPersister <OrderDetail>(); using (var cmd = NorthwindRepository.GetCommand(GetOrderDetailsSql)) { var orderDetails = NorthwindRepository.ExecuteInstance <OrderDetail>(persister, cmd, pageIndex, pageSize); Console.WriteLine(orderDetails); } }
public ActionResult AmountToShow(string searchTerm, int num) { var repo = new NorthwindRepository(Properties.Settings.Default.ConStr); var products = repo.SearchProductName(searchTerm); if (num == 0) { num = products.Count(); } return(Json(products.Take(num), JsonRequestBehavior.AllowGet)); }
static void Main(string[] args) { NorthwindRepository r = new NorthwindRepository(); //var empl = r.GetAllEmployees(i => i.ReportsTo == 2, i => i.LastName); //var empl = r.GetAllEmployees(i => i.LastName); var empl = r.GetAllEmployees(); foreach (var item in empl) { Console.WriteLine($"{item.Id}: {item.FirstName} {item.LastName}"); } }
/// <summary> /// Save Northwind metadata to a script file /// Certain tests will load this script dynamically so they can get metadata /// without making a Web API call /// </summary> public static void WriteNorthwindMetadataScriptFile() { var metadata = new NorthwindRepository().Metadata; var scriptFilename = HostingEnvironment.MapPath("~/tests/helpers/northwindMetadata.js"); const string prefix = "docCode.northwindMetadata = "; const string postfix = ";"; using (var writer = new StreamWriter(scriptFilename)) { writer.WriteLine(prefix + metadata + postfix); } }
public async System.Threading.Tasks.Task <ActionResult> InsertProduct(ProductsModel Product) { _northwindRepository = new NorthwindRepository(); var result = await _northwindRepository.InsertProduct(Product); //使用多執行緒的原因:一個動作可同時做多件事,但這個範例沒有做。 /* 正規的設計下,會制定標準化的回傳格式。讓接收端,了解該真實狀態。 * 另外也會將結果回傳給前端,這邊省略 */ return(RedirectToAction("Products", "Home")); }
public void Can_Create_Command_By_NamedQueryCommand_With_QueryKey(string queryKey) { NorthwindRepository.QueryProvider.Should().Not.Be.Null(); using (var cmd = NorthwindRepository.GetNamedQueryCommand(queryKey)) using (var dataTable = NorthwindRepository.ExecuteDataTable(cmd)) { Assert.IsNotNull(dataTable); Assert.IsFalse(dataTable.HasErrors); Assert.IsTrue(dataTable.Rows.Count > 0); } using (var dataTable = NorthwindRepository.ExecuteDataTable(queryKey)) { dataTable.Should().Not.Be.Null(); Assert.IsFalse(dataTable.HasErrors); Assert.IsTrue(dataTable.Rows.Count > 0); } }
public void Can_Create_Command_By_NamedQueryCommand_With_Section_And_QueryName(string section, string queryName) { if (NorthwindRepository.QueryProvider != null) { using (var cmd = NorthwindRepository.GetNamedQueryCommand(section, queryName)) using (var dataTable = NorthwindRepository.ExecuteDataTable(cmd)) { Assert.IsNotNull(dataTable); Assert.IsFalse(dataTable.HasErrors); Assert.IsTrue(dataTable.Rows.Count > 0); } var queryKey = string.Concat(section, ",", queryName); using (var dataTable = NorthwindRepository.ExecuteDataTable(queryKey)) { Assert.IsNotNull(dataTable); Assert.IsFalse(dataTable.HasErrors); Assert.IsTrue(dataTable.Rows.Count > 0); } } }
// Todo: inject via an interface rather than "new" the concrete class public NorthwindController(NorthwindRepository repository) { _repository = repository ?? new NorthwindRepository(); }
public ProductsController(NorthwindRepository context) { this.repository = context; }
// Todo: inject via an interface rather than "new" the concrete class protected MultiBaseController(NorthwindRepository repository) { Repository = repository ?? new NorthwindRepository(); }
public NorthwindController() { // Todo: inject via an interface rather than "new" the concrete class _repository = new NorthwindRepository(); }
public IRepository <TEntity> GetNorthwindEntities <TEntity>() where TEntity : class, IEntity { IRepository <TEntity> entityRepository = new NorthwindRepository <TEntity>(_northwindDb); return(entityRepository); }
public TerritoriesWebSvc() { _northwindRepository = new NorthwindRepository(WebConfigurationManager.ConnectionStrings["Northwind"].ConnectionString); }
public ActionResult GetSearchResults(string searchTerm) { var repo = new NorthwindRepository(Properties.Settings.Default.ConStr); return(Json(repo.SearchProductName(searchTerm), JsonRequestBehavior.AllowGet)); }
public ProductsController() { String cs = ConfigurationManager.ConnectionStrings["NorthwindSQL"].ConnectionString; _repository = new NorthwindRepository(new NorthwindDbContext(cs)); }
public DynamicColumnsAndRowsController(NorthwindRepository northwindRepository) { _northwindRepository = northwindRepository; }