private async Task <int> GetClientIdAsync() { var clientRepository = new ClientsRepository(billingoApi); var clients = await clientRepository.GetListAsync(1, 1); return(clients?.SingleOrDefault()?.Id ?? (await clientRepository.CreateAsync(new Client { Name = "Test Elek", Email = "*****@*****.**", Billing_address = new BillingAddress { Country = "Magyarország", Postcode = "1117", City = "Budapest", Street_name = "Test", Street_type = "utca", House_nr = "10", }, Bank = new Bank { Account_no = "11739009-23905470-" }, Defaults = new Defaults { Electronic_invoice = "true", Invoice_currency = "HUF" } })).Id); }
public ResponseModel <IEnumerable <ClientsModel> > Get(int idGroup) { var resp = new ResponseModel <IEnumerable <ClientsModel> >(); try { IClientsRepository appRepo = new ClientsRepository(new DataBaseContext()); var appList = appRepo.GetClientsModel(idGroup); if (appList != null && appList.Any()) { resp.Data = appList; resp.Status = 200; resp.Description = "OK"; } else { resp.Status = 200; resp.Description = "No clients"; resp.Data = null; } } catch (Exception ex) { resp.Status = 500; resp.Description = $"Error: {ex.Message}"; resp.Data = null; } return(resp); }
public static bool IsClientAdminButInOtherContext() { string prefix = new ClientsRepository().GetClient(GetCID()).ClientPrefix; return(IsUserInRoleInContext(RoleNames.ClientAdministrator) && !string.IsNullOrEmpty(prefix)); }
public static void SetUp() { _client = ClientsRepository.CreateNewClient("test"); _accountRepository = new AccountRepository(); _accountDeposit = _accountRepository.AddDepositAccount(_client); _depositRepository = new DepositRepository(); }
public ActionResult Users() { string clientName = string.Empty; IList <MembershipUser> users; if (AppContext.IsClientAdmin() && !AppContext.IsClientAdminButInOtherContext()) { users = MembershipService.GetAllUsers(); } else { clientName = new ClientsRepository().GetClientName(AppContext.GetCID()); users = MembershipService.GetClientUsers(AppContext.GetCID()); } UsersViewModel viewModel = new UsersViewModel() { Users = users, ClientName = clientName }; return(View(viewModel)); }
public HolidayTests(ITestOutputHelper output) { _output = output; var setup = new SetUp(); setup.Initialize(); _context = setup.HolidayDbContext; var mapper = setup.Mapper; var userManager = setup.InitializeUserManager(); _holidaysCount = setup.GetCount("holidays"); _configuration = setup.GetConfiguration(); _timeService = new TimeService(); var mockUserService = new Mock <IUserService>().Object; var mockOvertimeUtility = new Mock <IOvertimeUtility>().Object; _holidaysRepository = new HolidaysRepository(_context); _employeesRepository = new EmployeesRepository(_context, userManager); _clientsRepository = new ClientsRepository(_context); var holidayGuidsRepository = new HolidayGuidsRepository(_context); var mockNotificationSettingsService = new Mock <INotificationSettingsService>().Object; _employeesService = new EmployeesService(_employeesRepository, mapper, mockOvertimeUtility, _timeService, mockUserService, mockNotificationSettingsService, _configuration); _holidaysService = new HolidaysService(_holidaysRepository, _employeesRepository, mapper, _timeService, mockOvertimeUtility, _clientsRepository, mockUserService, _configuration, holidayGuidsRepository); }
public override void TestInitialize() { base.TestInitialize(); _appointments = new AppointmentsRepository(); _clients = new ClientsRepository(); _treatments = new TreatmentsRepository(); _technicians = new TechniciansRepository(); _clientData = GetRandom.Object <ClientData>(); var c = new global::Delux.Domain.Client.Client(_clientData); _clients.Add(c).GetAwaiter(); AddRandomClients(); _treatmentData = GetRandom.Object <TreatmentData>(); var tr = new global::Delux.Domain.Treatment.Treatment(_treatmentData); _treatments.Add(tr).GetAwaiter(); AddRandomTreatments(); _technicianData = GetRandom.Object <TechnicianData>(); var te = new global::Delux.Domain.Technician.Technician(_technicianData); _technicians.Add(te).GetAwaiter(); AddRandomTechnicians(); Obj = new TestClass(_appointments, _clients, _treatments, _technicians); }
private void UpdateTest() { const string newClientName = "New name"; using (var context = new Context()) { var clientsRepository = new ClientsRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); _clientDataMock.Client.ClientName = newClientName; clientsRepository.Update(_clientDataMock.Client); } using (var context = new Context()) { var clientsRepository = new ClientsRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); var downloadedClient = clientsRepository.Get(_clientDataMock.ClientId); Assert.AreEqual(newClientName, downloadedClient.ClientName); Assert.True(downloadedClient.Projects.Count > 0, "UpdateTest does not return related projects"); Assert.True(downloadedClient.Projects.All(p => p.Auditors.Count > 0), "UpdateTest does not return related auditors"); } }
public void Update_ExistingClient_Valid() { var clientsInMemory = new List <Client> { GetClient() }; var mockDbSet = new Mock <DbSet <Client> >(); PrepareQueryableMock(clientsInMemory, mockDbSet); //mocking add method mockDbSet.Setup(m => m.Add(It.IsAny <Client>())) .Callback <Client>(clientsInMemory.Add); var dbContext = new ClientsApiDbContext { Clients = mockDbSet.Object }; var repo = new ClientsRepository(dbContext); var client = GetClient(); client.City = "Belo Horizonte"; repo.Update(client); Assert.IsTrue(clientsInMemory.Count == 1); Assert.AreEqual("Belo Horizonte", clientsInMemory[0].City); }
public void AClientRepositoryIsInstantiatedEmpty() { var clientsRepository = new ClientsRepository(); var clients = clientsRepository.GetClients(); Assert.AreEqual(0, clients.Count); }
/// <summary> /// Загрузка окна, инициализация контроллеров, загрузка в listview данных и сброс управления. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void MetroWindow_Loaded(object sender, RoutedEventArgs e) { Firts_Start = true; DBConnection oDBConnection = new DBConnection(); await oDBConnection.InitializeDatabase(); oOrdersRepository = new OrdersRepository(oDBConnection); oClientsRepository = new ClientsRepository(oDBConnection); oCardsRepository = new CardsRepository(oDBConnection); oBouquetsRepository = new BouquetsRepository(oDBConnection); oContentsRepository = new ContentsRepository(oDBConnection); oCartsRepository = new CartsRepository(oDBConnection); oAccessoriesRepository = new AccessoriesRepository(oDBConnection); oFlowersRepository = new FlowersRepository(oDBConnection); oSpecialDealsRepository = new SpecialDealsRepository(oDBConnection); oDiscountRepository = new DiscountsRepository(oDBConnection); conn = oDBConnection.GetAsyncConnection(); lCart_Bouquet = new List <Cart_Bouquet>(); await Update_ListView_Clients(); await Update_ListView_Bouquets(); Clear_Control_All(); }
public void Delete_ExistingClient() { var client = GetClient(); var clientsInMemory = new List <Client> { client }; var mockDbSet = new Mock <DbSet <Client> >(); PrepareQueryableMock(clientsInMemory, mockDbSet); //mocking add method mockDbSet.Setup(m => m.Remove(It.IsAny <Client>())) .Returns(() => client) .Callback(() => clientsInMemory.Remove(client)); var dbContext = new ClientsApiDbContext { Clients = mockDbSet.Object }; var repo = new ClientsRepository(dbContext); repo.Delete(client.CPF); Assert.IsTrue(clientsInMemory.Count == 0); }
public void EditClient(AddEditClient clientFromView, out DefaultError outError) { if (CheckClient(clientFromView, out outError)) { ClientsRepository.EditClient(SetClientData(clientFromView)); } }
public ResponseModel <ClientsModel> GetById(int id) { var resp = new ResponseModel <ClientsModel>(); try { IClientsRepository appRepo = new ClientsRepository(new DataBaseContext()); var app = appRepo.GetClientsModelById(id); if (app != null) { resp.Data = app; resp.Status = 200; resp.Description = "OK"; } else { resp.Status = 200; resp.Data = null; resp.Description = "Application not found"; } } catch (Exception ex) { resp.Status = 500; resp.Description = $"Error: {ex.Message}"; resp.Data = null; } return(resp); }
private void SetList() { Clients.Clear(); foreach (var item in ClientsRepository.GetInstance().GetAll()) { Clients.Add(item as Clients); } }
public ActionResult GetClients() { var clients = new ClientsRepository().Items.ToList(); var res = Mapper.Map <IList <Client>, IList <ClientModel> >(clients); return(PartialView("ClientView", res)); }
public RepositoryUnit(DataBaseContext context) { _context = context; Phones = new PhoneRepository(_context); Oranizations = new OraganizationRepository(_context); Managers = new ManagerRepository(_context); Clients = new ClientsRepository(_context); }
private ClientInfo CreateClientTest(string phoneNumber) { Assert.IsTrue(ClientsRepository.GetInstance().Insert(ClientTest)); ClientInfo tempClient = ClientsRepository.GetInstance().SelectByPhone(phoneNumber); return(tempClient); }
public MainForm() { InitializeComponent(); _clientsRepository = new ClientsRepository(); _productsRepository = new ProductsRepository(); _ordersRepository = new OrdersRepository(); FillGrids(); }
private async Task Initialize_Database() { DBConnection oDBConnection = new DBConnection(); await oDBConnection.InitializeDatabase(); oClients = new ClientsRepository(oDBConnection); oConstants = new ConstantsRepository(oDBConnection); }
public UnitOfWork(ApplicationDbContext context) { _context = context; Products = new ProductsRepository(_context); Clients = new ClientsRepository(_context); Configuration = new ConfigurationRepository(_context); Provider = new ProviderRepository(_context); Sale = new SaleRepository(_context); }
public ActionResult NewClient(FormCollection formValues) { if (formValues["Submit"].Equals("Zapisz", StringComparison.InvariantCultureIgnoreCase)) { ClientsRepository cr = new ClientsRepository(); Client client = new Client(); UpdateModel <Client>(client); if (ValidateClient(client.ClientName, client.ClientPrefix)) { try { cr.CreateClient(client); int newClientID = cr.GetAllClients().Where(c => c.ClientName == client.ClientName).First().ClientID; string newUserName = string.Format("{0}{1}", client.ClientPrefix, "Admin"); string newAdminGroupName = string.Format("{0}{1}", client.ClientPrefix, "Administratorzy"); string newUsersGroupName = string.Format("{0}{1}", client.ClientPrefix, "Użytkownicy"); MembershipUser newUser = Membership.CreateUser(newUserName, newUserName); cr.AssignUserToClient((Guid)newUser.ProviderUserKey, newClientID); Guid newGroupGuid = _repository.AddGroup(newUsersGroupName, newClientID); _repository.GetGroup(newGroupGuid).ClientID = newClientID; newGroupGuid = _repository.AddGroup(newAdminGroupName, newClientID); _repository.GetGroup(newGroupGuid).ClientID = newClientID; // _repository.SubmitChanges(); _repository.AddUserToGroup((Guid)newUser.ProviderUserKey, newGroupGuid); _repository.AddRoleToGroup(RoleNames.Administrator, newGroupGuid); _repository.AddUserToGroup((Guid)Membership.GetUser().ProviderUserKey, newGroupGuid); string scansDir = Path.Combine(Properties.Settings.Default.ScansRootDirectory, client.ClientPrefix + "scans"); if (!Directory.Exists(scansDir)) { Directory.CreateDirectory(scansDir); } } catch (Exception ex) { ModelState.AddModelError("AllClient", ex.Message); return(View()); } } else { return(View()); } } return(RedirectToAction("Clients")); }
public void TestClientsSelectAll() { ClientInfo tempClient = CreateClientTest(PHONE_NUMBER); var QuantityClients = ClientsRepository.GetInstance().SelectAll(); Assert.IsTrue(QuantityClients.Exists(x => x.Id == tempClient.Id)); DeleteClientTest(tempClient); }
public void DelClient(string clientId, out DefaultError outError) { outError = new DefaultError(); if (ClientsRepository.GetClientById(clientId) == null) { outError.ErrorMessage = "Ошибка удаления. Клиент отсутствует в базе!"; return; } ClientsRepository.DelClient(clientId); }
public static void SetUp() { _accountRepository = new AccountRepository(); Client client = ClientsRepository.CreateNewClient("test"); _accountCard = _accountRepository.AddCardAccount(client); _accountCard.Balance = startBalanceCardAccount; _accountDeposit = _accountRepository.AddDepositAccount(client); _accountInterest = _accountRepository.AddInterestAccount(client); }
public void TestClientsSelectByPhone() { ClientInfo tempClient = CreateClientTest(PHONE_NUMBER); ClientInfo client = ClientsRepository.GetInstance().SelectByPhone(tempClient.Phone); Assert.AreEqual(PHONE_NUMBER, client.Phone); DeleteClientTest(tempClient); }
public async Task GetAll_NoData_ReturnsEmptyList() { // Arrange var sut = new ClientsRepository(this.mongoCollection); // Act var actual = await sut.GetAll(); // Assert actual.Should().BeEmpty(); }
public void AClientCanbeAddedInClientRepository() { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var client = new Client(socket); var clientsRepository = new ClientsRepository(); clientsRepository.Add(client); var clients = clientsRepository.GetClients(); Assert.AreEqual(1, clients.Count); }
public void TestClientsUpdate() { ClientInfo tempClient = CreateClientTest(PHONE_NUMBER); tempClient.Readed = true; tempClient.LastReading += tempClient.LastReading; Assert.IsTrue(ClientsRepository.GetInstance().Update(tempClient)); DeleteClientTest(tempClient); }
public void TestClientsSelectByDocument() { ClientInfo tempClient = CreateClientTest(PHONE_NUMBER); ClientInfo client = ClientsRepository.GetInstance().SelectByDocument(tempClient.DocumentTypeId, tempClient.DocumentNumber); Assert.AreEqual(DOCUMENT_TYPE_ID, client.DocumentTypeId); Assert.AreEqual(DOCUMENT_NUMBER, client.DocumentNumber); DeleteClientTest(tempClient); }
public ActionResult GetClients() { var clients = new ClientsRepository().Items.ToList(); var res = Mapper.Map<IList<Client>, IList<ClientModel>>(clients); return PartialView("ClientView", res); }
public ActionResult EditClient(int id) { var _client = new ClientsRepository().ClientModelById(id); if (_client == null) return View("Error"); var client = Mapper.Map<ClientModel>(_client); return PartialView("EditClientView", client); }