public async Task CustomersMiddleNameisAAA() { //arrange //ICustomerRepository repo = GetInMemoryProductRepository(); var options = new DbContextOptionsBuilder <BankContext>().UseInMemoryDatabase("CanSaveCustomers").Options; //act //run the test against one instance of the context using (var context = new BankContext(options)) { var repo = new BankRepo(context); await repo.AddCustomerAsync(new Customer { FirstName = "Customer1FN", LastName = "Customer1LN", MiddleName = "SomethingElse" }); } //assert //run against another instance of the context to verify correct data saved to the db //run against the actual db rather than calling tehe repo to retrieve data using (var context = new BankContext(options)) { var firstCust = context.Customers.FirstOrDefault(); Assert.AreEqual("Customer1FN", firstCust.FirstName); Assert.AreEqual("Customer1LN", firstCust.LastName); Assert.AreEqual("AAA", firstCust.MiddleName); } }
public ActionResult Edit(int id) { var data = BankRepo.Find(id); if (data == null) { throw new InvalidOperationException("操作錯誤"); } return(View(data)); }
public ActionResult Details(int id) { if (id == 0) { throw new ArgumentException("參數錯誤"); } var data = BankRepo.Find(id); if (data == null) { throw new InvalidOperationException("操作錯誤"); } return(View(data)); }
public ActionResult Save(客戶銀行資訊 model) { var msg = "客戶銀行資訊" + (model.Id == 0 ? "新增" : "更新") + "成功"; if (ModelState.IsValid) { try { BankRepo.Save(model); BankRepo.UnitOfWork.Commit(); return(Json(new { id = model.Id, isValid = true, message = HttpUtility.HtmlEncode(msg) })); } catch (Exception ex) { return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶銀行資訊儲存失敗。錯誤訊息: " + ex.Message) })); } } msg = string.Join(" ", ModelState.Values.SelectMany(p => p.Errors).Select(p => p.ErrorMessage)); return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶銀行資訊儲存時,驗證欄位失敗。" + msg) })); }
public ActionResult Delete(int id) { var data = BankRepo.Find(id); var DelMsg = "客戶銀行資訊不存在。"; if (data != null) { try { BankRepo.Delete(data); BankRepo.UnitOfWork.Commit(); DelMsg = "客戶銀行資訊刪除成功。"; } catch (Exception ex) { DelMsg = "客戶銀行資訊刪除失敗。錯誤訊息: " + ex.Message; } } TempData["DelMsg"] = DelMsg; return(RedirectToAction("Index")); }
private static void Main(string[] args) { var list = BankRepo.GetList(); foreach (var item in list) { Console.WriteLine("Informações da conta"); Console.WriteLine("- - -"); Console.WriteLine($"Nome: {item.User.Name}"); Console.WriteLine($"Rua: {item.User.Address.Street}"); Console.WriteLine($"Cidade: {item.User.Address.City}"); Console.WriteLine("- - -"); Console.WriteLine($"Banco: {item.Bank.Name}"); Console.WriteLine($"Agência: {item.Branch}"); Console.WriteLine($"Conta: {item.Account}"); Console.WriteLine($"Categoria de Conta: {item.AccountCategory.Name}"); Console.WriteLine($"Tipo de Conta: {item.AccountType.Name}"); Console.WriteLine($"Moeda: {item.Currency.Name}"); Console.WriteLine($"Gerente: {item.Manager.Name}"); Console.WriteLine(""); } Console.ReadLine(); }
public ActionResult Create() { ViewBag.Company = CompanyRepo.CompanyNameList(0); return(View("Edit", BankRepo.Find(0))); }
public ActionResult ExportXLSXList(QueryBankModel model) { var bandinfoData = BankRepo.Query(model); return(File(BankRepo.ExportXLSX(bandinfoData), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "客戶銀行資料.xlsx")); }
public ActionResult ExportXLSList(QueryBankModel model) { var bandinfoData = BankRepo.Query(model); return(File(BankRepo.ExportXLS(bandinfoData), "application/vnd.ms-excel", "客戶銀行資料.xls")); }
// GET: /BankInfo public ActionResult Index(QueryBankModel model) { return(View(BankRepo.Query(model, 1))); }
public BankManager() { _bankRepo = new BankRepo(); }
public HomeController(BankRepo grepo) { this.GRepo = grepo; }
public HomeController() { this.GRepo = new WorkingBankRepo(); }