Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public static bool IsClientAdminButInOtherContext()
        {
            string prefix = new ClientsRepository().GetClient(GetCID()).ClientPrefix;

            return(IsUserInRoleInContext(RoleNames.ClientAdministrator) &&
                   !string.IsNullOrEmpty(prefix));
        }
Пример #4
0
 public static void SetUp()
 {
     _client            = ClientsRepository.CreateNewClient("test");
     _accountRepository = new AccountRepository();
     _accountDeposit    = _accountRepository.AddDepositAccount(_client);
     _depositRepository = new DepositRepository();
 }
Пример #5
0
        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));
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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");
            }
        }
Пример #9
0
        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);
        }
Пример #10
0
        public void AClientRepositoryIsInstantiatedEmpty()
        {
            var clientsRepository = new ClientsRepository();
            var clients           = clientsRepository.GetClients();

            Assert.AreEqual(0, clients.Count);
        }
Пример #11
0
        /// <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();
        }
Пример #12
0
        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));
     }
 }
Пример #14
0
        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);
        }
Пример #15
0
 private void SetList()
 {
     Clients.Clear();
     foreach (var item in ClientsRepository.GetInstance().GetAll())
     {
         Clients.Add(item as Clients);
     }
 }
Пример #16
0
        public ActionResult GetClients()
        {
            var clients = new ClientsRepository().Items.ToList();

            var res = Mapper.Map <IList <Client>, IList <ClientModel> >(clients);

            return(PartialView("ClientView", res));
        }
Пример #17
0
 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);
        }
Пример #19
0
 public MainForm()
 {
     InitializeComponent();
     _clientsRepository  = new ClientsRepository();
     _productsRepository = new ProductsRepository();
     _ordersRepository   = new OrdersRepository();
     FillGrids();
 }
Пример #20
0
        private async Task Initialize_Database()
        {
            DBConnection oDBConnection = new DBConnection();

            await oDBConnection.InitializeDatabase();

            oClients   = new ClientsRepository(oDBConnection);
            oConstants = new ConstantsRepository(oDBConnection);
        }
Пример #21
0
 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);
 }
Пример #22
0
        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);
 }
Пример #25
0
        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);
        }
Пример #27
0
        public async Task GetAll_NoData_ReturnsEmptyList()
        {
            // Arrange
            var sut = new ClientsRepository(this.mongoCollection);

            // Act
            var actual = await sut.GetAll();

            // Assert
            actual.Should().BeEmpty();
        }
Пример #28
0
        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);
        }
Пример #31
0
        public ActionResult GetClients()
        {
            var clients = new ClientsRepository().Items.ToList();

            var res = Mapper.Map<IList<Client>, IList<ClientModel>>(clients);
            return PartialView("ClientView", res);
        }
Пример #32
0
 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);
 }