public 客戶資料Controller() { 客戶資料repo = RepositoryHelper.Get客戶資料Repository(); listItems = 客戶資料repo.GetListItem(); ViewBag.分類名稱 = listItems; }
public async void ReverseEngineerCodeFirst(Project project) { try { var dteH = new EnvDteHelper(); var revEng = new EfCoreReverseEngineer(); if (_package.Dte2.Mode == vsIDEMode.vsIDEModeDebug) { EnvDteHelper.ShowError("Cannot generate code while debugging"); return; } var startTime = DateTime.Now; var projectPath = project.Properties.Item("FullPath").Value.ToString(); var optionsPath = Path.Combine(projectPath, "efpt.config.json"); var databaseList = EnvDteHelper.GetDataConnections(_package); var psd = new PickServerDatabaseDialog(databaseList, _package); var diagRes = psd.ShowModal(); if (!diagRes.HasValue || !diagRes.Value) { return; } // Show dialog with SqlClient selected by default _package.Dte2.StatusBar.Text = "Loading schema information..."; var dbInfo = psd.SelectedDatabase.Value; if (dbInfo.DatabaseType == DatabaseType.SQLCE35) { EnvDteHelper.ShowError($"Unsupported provider: {dbInfo.ServerVersion}"); return; } var options = TryReadOptions(optionsPath); var ptd = new PickTablesDialog { IncludeTables = true }; using (var repository = RepositoryHelper.CreateRepository(dbInfo)) { ptd.Tables = repository.GetAllTableNamesForExclusion(); } if (options != null && options.Tables.Count > 0) { ptd.SelectedTables = options.Tables; } var res = ptd.ShowModal(); if (!res.HasValue || !res.Value) { return; } var classBasis = RepositoryHelper.GetClassBasis(dbInfo.ConnectionString, dbInfo.DatabaseType); var model = revEng.GenerateClassName(classBasis) + "Context"; var packageResult = dteH.ContainsEfCoreReference(project, dbInfo.DatabaseType); var modelDialog = new EfCoreModelDialog(options) { InstallNuGetPackage = !packageResult.Item1, ModelName = options != null ? options.ContextClassName : model, ProjectName = project.Name, NameSpace = options != null ? options.ProjectRootNamespace : project.Properties.Item("DefaultNamespace").Value.ToString() }; _package.Dte2.StatusBar.Text = "Getting options..."; var result = modelDialog.ShowModal(); if (!result.HasValue || result.Value != true) { return; } options = new ReverseEngineerOptions { UseFluentApiOnly = !modelDialog.UseDataAnnotations, ConnectionString = dbInfo.ConnectionString, ContextClassName = modelDialog.ModelName, DatabaseType = (ReverseEngineer20.DatabaseType)dbInfo.DatabaseType, ProjectPath = projectPath, OutputPath = modelDialog.OutputPath, ProjectRootNamespace = modelDialog.NameSpace, UseDatabaseNames = modelDialog.UseDatabaseNames, UseInflector = modelDialog.UsePluralizer, IdReplace = modelDialog.ReplaceId, UseHandleBars = modelDialog.UseHandelbars, IncludeConnectionString = modelDialog.IncludeConnectionString, SelectedToBeGenerated = modelDialog.SelectedTobeGenerated, Tables = ptd.Tables }; _package.Dte2.StatusBar.Text = "Generating code..."; var tfm = project.Properties.Item("TargetFrameworkMoniker").Value.ToString(); bool isNetCore = tfm.Contains(".NETCoreApp,Version=v2.0"); bool isNetStandard = tfm.Contains(".NETStandard,Version=v2.0"); if (modelDialog.UseHandelbars) { var dropped = (DropTemplates(projectPath)); if (dropped && !isNetCore && !isNetStandard) { project.ProjectItems.AddFromDirectory(Path.Combine(projectPath, "CodeTemplates")); } } var revEngResult = revEng.GenerateFiles(options); if (modelDialog.SelectedTobeGenerated == 0 || modelDialog.SelectedTobeGenerated == 2) { foreach (var filePath in revEngResult.EntityTypeFilePaths) { project.ProjectItems.AddFromFile(filePath); } if (modelDialog.SelectedTobeGenerated == 2) { if (File.Exists(revEngResult.ContextFilePath)) { File.Delete(revEngResult.ContextFilePath); } } } if (modelDialog.SelectedTobeGenerated == 0 || modelDialog.SelectedTobeGenerated == 1) { project.ProjectItems.AddFromFile(revEngResult.ContextFilePath); if (!isNetCore && !isNetStandard) { _package.Dte2.ItemOperations.OpenFile(revEngResult.ContextFilePath); } if (modelDialog.SelectedTobeGenerated == 1) { foreach (var filePath in revEngResult.EntityTypeFilePaths) { if (File.Exists(filePath)) { File.Delete(filePath); } } } } var missingProviderPackage = packageResult.Item1 ? null : packageResult.Item2; if (modelDialog.InstallNuGetPackage) { missingProviderPackage = null; } _package.Dte2.StatusBar.Text = "Reporting result..."; var errors = ReportRevEngErrors(revEngResult, missingProviderPackage); SaveOptions(project, optionsPath, options); if (modelDialog.InstallNuGetPackage) { _package.Dte2.StatusBar.Text = "Installing EF Core provider package"; var nuGetHelper = new NuGetHelper(); await nuGetHelper.InstallPackageAsync(packageResult.Item2, project); } var duration = DateTime.Now - startTime; _package.Dte2.StatusBar.Text = $"Reverse engineer completed in {duration:h\\:mm\\:ss}"; EnvDteHelper.ShowMessage(errors); if (revEngResult.EntityErrors.Count > 0) { _package.LogError(revEngResult.EntityErrors, null); } if (revEngResult.EntityWarnings.Count > 0) { _package.LogError(revEngResult.EntityWarnings, null); } Telemetry.TrackEvent("PowerTools.ReverseEngineer"); } catch (AggregateException ae) { foreach (var innerException in ae.Flatten().InnerExceptions) { _package.LogError(new List <string>(), innerException); } } catch (Exception exception) { _package.LogError(new List <string>(), exception); } }
public AccountController() { repo = RepositoryHelper.Get客戶資料Repository(); }
public 客戶銀行資訊Controller() { 客戶資料repo = RepositoryHelper.Get客戶資料Repository(); 客戶銀行資訊repo = RepositoryHelper.Get客戶銀行資訊Repository(客戶資料repo.UnitOfWork); }
public async Task <IEnumerable <MaturityLevelRecord> > GetAllAsync() { return(await RepositoryHelper.GetAllAsync <MaturityLevelRecord>()); }
public async Task DeleteAsync(Guid id) { await RepositoryHelper.DeleteAsync <MaturityLevelRecord>(new MaturityLevelRecord { Id = id.ToByteArray() }); }
public LoginController() { repo = RepositoryHelper.Get客戶資料Repository(); }
public async Task CreateAsync(MaturityLevelRecord maturityLevel) { await RepositoryHelper.InsertAsync <MaturityLevelRecord>(maturityLevel); }
public void SetTests() { RepositoryHelper helper = new RepositoryHelper(); items = helper.GetItems(); categories = helper.GetCategories(); users = helper.GetUsers(); orders = helper.GetOrders(); orderDeliveryMethods = helper.GetOrderDeliveryMethods(); orderPayMethods = helper.GetOrderPayMethods(); pageSize = 2; _orderService = new Mock <IOrderService>(); _orderService.Setup(x => x.OrdersCount()) .ReturnsAsync(orders.Count); _orderService.Setup(x => x.GetOrders(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync((int skip, int take) => orders.Skip(skip).Take(take)); _orderService.Setup(x => x.GetOrderDeliveryMethods()) .ReturnsAsync(orderDeliveryMethods); _orderService.Setup(x => x.GetOrderPayMethods()) .ReturnsAsync(orderPayMethods); _orderService.Setup(x => x.AddDeliveryMethod(It.IsAny <OrderDeliveryMethod>())) .ReturnsAsync((OrderDeliveryMethod odm) => { var newId = orderDeliveryMethods.Max(x => x.Id) + 1; odm.Id = newId; orderDeliveryMethods.Add(odm); return(newId); }); _orderService.Setup(x => x.UpdateDeliveryMethod(It.IsAny <OrderDeliveryMethod>())) .Returns(async(OrderDeliveryMethod odm) => { var order = orderDeliveryMethods.SingleOrDefault(x => x.Id == odm.Id); order.name = odm.name; await Task.CompletedTask; }); _orderService.Setup(x => x.RemoveDeliveryMethod(It.IsAny <int>())) .Returns(async(int id) => { var odm = orderDeliveryMethods.SingleOrDefault(x => x.Id == id); orderDeliveryMethods.Remove(odm); await Task.CompletedTask; }); _orderService.Setup(x => x.AddPayMethod(It.IsAny <OrderPayMethod>())) .ReturnsAsync((OrderPayMethod opm) => { var newId = orderPayMethods.Max(x => x.Id) + 1; opm.Id = newId; orderPayMethods.Add(opm); return(newId); }); _orderService.Setup(x => x.UpdatePayMethod(It.IsAny <OrderPayMethod>())) .Returns(async(OrderPayMethod opm) => { var order = orderPayMethods.SingleOrDefault(x => x.Id == opm.Id); order.name = opm.name; await Task.CompletedTask; }); _orderService.Setup(x => x.RemovePayMethod(It.IsAny <int>())) .Returns(async(int id) => { var opm = orderPayMethods.SingleOrDefault(x => x.Id == id); orderPayMethods.Remove(opm); await Task.CompletedTask; }); _itemService = new Mock <IItemService>(); _itemService.Setup(x => x.GetCategories()) .ReturnsAsync(categories); _itemService.Setup(x => x.ItemsCount()) .ReturnsAsync(items.Count); _itemService.Setup(x => x.GetItems(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync((int skip, int take) => items.Skip(skip).Take(take).ToList() ); _itemService.Setup(x => x.AddItem(It.IsAny <Item>())) .ReturnsAsync((Item item) => { int newId = items.Max(x => x.Id) + 1; item.Id = newId; items.Add(item); return(newId); }); _itemService.Setup(x => x.DeleteItem(It.IsAny <int>())); _itemService.Setup(x => x.AddCategory(It.IsAny <Category>())) .ReturnsAsync((Category cat) => { var newId = categories.Max(x => x.Id) + 1; cat.Id = newId; categories.Add(cat); return(newId); }); _itemService.Setup(x => x.UpdateCategory(It.IsAny <Category>())) .Returns(async(Category category) => { var cat = categories.SingleOrDefault(x => x.Id == category.Id); cat.name = category.name; await Task.CompletedTask; }); _itemService.Setup(x => x.DeleteCategory(It.IsAny <int>())); _userService = new Mock <IUserService>(); _userService.Setup(x => x.DeleteUser(It.IsAny <User>())); _userService.Setup(x => x.UsersCount()) .ReturnsAsync(users.Count); _userService.Setup(x => x.GetUsers(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync((int skip, int take) => users.Skip(skip).Take(take).ToList()); _env = new Mock <IWebHostEnvironment>(); _env.Setup(x => x.WebRootPath) .Returns("//"); _saveFileService = new Mock <ISaveFile>(); _saveFileService.Setup(x => x.SaveFile(It.IsAny <IFormFile>(), It.IsAny <string>())) .ReturnsAsync((IFormFile file, string path) => file.FileName); controller = new AdminController(_itemService.Object, _orderService.Object, _userService.Object, _env.Object, _saveFileService.Object, pageSize); }
public 客戶資料Controller() { 客戶資料repo = RepositoryHelper.Get客戶資料Repository(); 客戶類型repo = RepositoryHelper.Get客戶類型Repository(客戶資料repo.UnitOfWork); 客戶聯絡人repo = RepositoryHelper.Get客戶聯絡人Repository(); }
public 客戶資料Controller() { var unitOfWork = new EFUnitOfWork(); customerRepo = RepositoryHelper.Get客戶資料Repository(unitOfWork); }
public CustomersController() { this.CustomerRepo = RepositoryHelper.Get客戶資料Repository(); this.CustomerTypeRepo = RepositoryHelper.Get客戶類別Repository(this.CustomerRepo.UnitOfWork); this.ContactsRepo = RepositoryHelper.Get客戶聯絡人Repository(this.CustomerRepo.UnitOfWork); }
/// <summary> /// Initializes a new instance of the <see cref="EmployeeBusinessObject"/> class. /// </summary> public EmployeeBusinessObject() { this.context = RepositoryHelper.GetDbContext(); this.uow = RepositoryHelper.GetUnitOfWork(context); this.employeeRepository = RepositoryHelper.GetEmployeeRepository(context); }
public async Task UpdateAsync(MaturityCategoryRecord maturityCategory) { await RepositoryHelper.UpdateAsync <MaturityCategoryRecord>(maturityCategory); }
public async Task CreateAsync(UserRecord user) { await RepositoryHelper.InsertAsync <UserRecord>(user); }
public VWLISTCOUNTController() { repo = RepositoryHelper.Get客戶資料Repository(qry.UnitOfWork); }
public async Task <IEnumerable <UserRecord> > GetAllAsync() { return(await RepositoryHelper.GetAllAsync <UserRecord>()); }
public async Task <MaturityLevelRecord> GetAsync(Guid id) { return(await RepositoryHelper.GetByIdAsync <MaturityLevelRecord>(id.ToByteArray())); }
public async Task UpdateAsync(UserRecord user) { await RepositoryHelper.UpdateAsync <UserRecord>(user); }
public async Task UpdateAsync(MaturityLevelRecord maturityLevel) { await RepositoryHelper.UpdateAsync <MaturityLevelRecord>(maturityLevel); }
public async Task DeleteAsync(Guid id) { await RepositoryHelper.DeleteAsync <UserRecord>(new UserRecord { Id = id.ToByteArray() }); }
public void SetTests() { RepositoryHelper helper = new RepositoryHelper(); users = helper.GetUsers(); carts = helper.GetCarts(); orders = helper.GetOrders(); cartItems = helper.GetCartItems(); orderItems = helper.GetOrderItems(); orderDeliveryMethods = helper.GetOrderDeliveryMethods(); orderPayMethods = helper.GetOrderPayMethods(); _orderService = new Mock <IOrderService>(); _orderService.Setup(x => x.GetOrderPayMethods()) .ReturnsAsync(orderPayMethods); _orderService.Setup(x => x.GetOrderDeliveryMethods()) .ReturnsAsync(orderDeliveryMethods); _orderService.Setup(x => x.CreateOrder(It.IsAny <Order>(), It.IsAny <int>())) .ReturnsAsync((Order order, int cartId) => { var orderId = orders.Max(x => x.Id) + 1; List <CartItem> items = new List <CartItem>(); foreach (var item in items) { order.OrderItems.Add(new OrderItem() { ItemId = item.ItemId, OrderId = orderId, quantity = item.quantity }); } order.Id = orderId; orders.Add(order); return(orderId); }); _orderService.Setup(x => x.GetOrderDetailed(It.IsAny <int>())) .ReturnsAsync((int id) => { Order order = orders.SingleOrDefault(x => x.Id == id); if (order != null) { order.OrderDeliveryMethod = orderDeliveryMethods.SingleOrDefault(x => x.Id == order.OrderDeliveryMethodId); order.OrderPayMethod = orderPayMethods.SingleOrDefault(x => x.Id == order.OrderPayMethodId); order.OrderItems = orderItems.Where(x => x.OrderId == id).ToList(); } return(order); }); _userService = new Mock <IUserService>(); _userService.Setup(x => x.GetUser(It.IsAny <int>())) .ReturnsAsync((int id) => users.SingleOrDefault(x => x.Id == id)); _cartService = new Mock <ICartService>(); _cartService.Setup(x => x.GetCart(It.IsAny <int>())) .ReturnsAsync((int id) => carts.SingleOrDefault(x => x.Id == id)); controller = new OrderController(_orderService.Object, _cartService.Object, _userService.Object); var user = new ClaimsPrincipal( new ClaimsIdentity( new Claim[] { new Claim(ClaimsIdentity.DefaultNameClaimType, "2"), new Claim(ClaimsIdentity.DefaultRoleClaimType, "User") }, "ApplicationCookie", ClaimsIdentity.DefaultNameClaimType, ClaimsIdentity.DefaultRoleClaimType)); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext { User = user }; }
public 客戶聯絡人Controller() { repo客戶資料 = RepositoryHelper.Get客戶資料Repository(repo.UnitOfWork); }
public ClientsController() { repo = RepositoryHelper.GetClientRepository(); occuRepo = RepositoryHelper.GetOccupationRepository(repo.UnitOfWork); }
public CustomerInfoManageController() { 客戶聯絡人repo = RepositoryHelper.Get客戶聯絡人Repository(客戶資料repo.UnitOfWork); }
public ARController() { repo = RepositoryHelper.GetDepartmentRepository(); }
public 客戶聯絡人Controller() { repo = RepositoryHelper.Get客戶聯絡人Repository(); repoCust = RepositoryHelper.Get客戶資料Repository(repo.UnitOfWork); }
public void TestGetUnitofworkFromContainer() { EmployeeRepository employeeRepository1 = RepositoryHelper.GetEmployeeRepository(); Assert.NotNull(employeeRepository1); }
public 客戶銀行資訊Controller() { custBankRepo = RepositoryHelper.Get客戶銀行資訊Repository(); customerRepo = RepositoryHelper.Get客戶資料Repository(custBankRepo.UnitOfWork); }
public void SetUp() { this.accountRepo = new Mock<IRepository<BankAccount, string>>(); this.typeRepo = new Mock<IRepository<BankOperationType, string>>(); this.cardRepo = new Mock<IRepository<Card, string>>(); this.repositoryHelper = new RepositoryHelper(accountRepo.Object, typeRepo.Object, cardRepo.Object); IFillOperationFromDescriptionChain chain = new WyplataBankomat(repositoryHelper, parseHelper, new OperacjaKarta(repositoryHelper, parseHelper, new Przelew(repositoryHelper, new PrzelewPrzychodzacy(repositoryHelper, parseHelper, new PrzelewWychodzacy(repositoryHelper, new InnaOperacja(repositoryHelper)))))); this.parser = new BgzBnpParibasParser( parseHelper, repositoryHelper, new WyplataBankomat(repositoryHelper, parseHelper, chain)); }
public async Task CreateAsync(MaturityCategoryRecord maturityCategory) { await RepositoryHelper.InsertAsync <MaturityCategoryRecord>(maturityCategory); }