Exemple #1
0
 public HttpResponseMessage GetClients()
 {
     try
     {
         var clients = _repo.GetClients().ToList();
         return(Request.CreateResponse(HttpStatusCode.OK, clients));
     }
     catch
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }
        public async Task GetClients_Should_Return_Correct_Count()
        {
            // Arrange
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            _clientService            = new BankApplication.Service.Service.ClientService(dbContext, _mapper);
            const int clientCount = 4;

            // Act
            var actual = _clientService.GetClients();

            // Assert
            Assert.AreEqual(clientCount, actual.Count());
        }
Exemple #3
0
        private async Task UpdateDataGridViewClients()
        {
            var clients = await _clientsRepository.GetClients();

            dataGridViewClients.Rows.Clear();
            dataGridViewClients.Columns[0].Width = clients.Count > 4 ? 348 : 365;
            foreach (var client in clients)
            {
                dataGridViewClients.Rows.Add(new[] {
                    client.Id.ToString(),
                    client.FIO,
                    client.ContactNumber.ToString(),
                    client.Address
                });
            }
            ClearDataGridViewClientsSelection();
        }
Exemple #4
0
        public async Task GetClients_ShouldReturnCorrectAmount()
        {
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            clientsRepository         = new ClientService(dbContext, mapper);

            //Arrange
            var expectedAmount = await dbContext.Clients.CountAsync();

            //Actual
            var actual = clientsRepository
                         .GetClients()
                         .Count();

            //Assert
            Assert.Equal(expectedAmount, actual);
        }
        public string GetClients()
        {
            //get the parameters from the Datatable
            var dtParams = new DtParameters(Request);

            var entities     = _rep.GetClients();
            int totalRecords = entities.Count();

            if (dtParams.IsBeingSearched)
            {
                entities = entities.Where(e => e.Name.ToLower().Contains(dtParams.SearchValue) ||
                                          (e.Mobile != null ? e.Mobile.ToLower().Contains(dtParams.SearchValue) : false));
            }

            int filteredRecords = entities.Count();

            if (dtParams.IsBeingFiltered)
            {
                entities = Filter(entities, dtParams.FilterColIndex, dtParams.FilterAsc);
            }
            else
            {
                //defaultOrder
                entities = entities.OrderBy(e => e.Name);
            }

            var data = entities.Skip(dtParams.Skip).Take(dtParams.PageSize)
                       .ToList().Select(c => new ClientW
            {
                Name   = c.Name,
                Mobile = c.Mobile,
                Id     = c.Id
            });

            var jsonResult = new JqueryListResult <ClientW>(
                data,
                dtParams.Draw,
                filteredRecords,
                totalRecords);

            var json = JsonConvert.SerializeObject(jsonResult);

            return(json);
        }
Exemple #6
0
        public IQueryable <ClientModel> GetClients()
        {
            var clients = _clientsRepository.GetClients().ProjectTo <ClientModel>(_mapper.ConfigurationProvider);

            return(clients);
        }
Exemple #7
0
 public IEnumerable <ClientDTO> GetClients()
 {
     return(_service.GetClients());
 }
        public async Task <IActionResult> GetClients()
        {
            var clients = await clientsRepository.GetClients();

            return(Ok(clients));
        }
 public ActionResult GetClients()
 {
     ViewData["Clients"] = _clientsRepository.GetClients();
     return(View());
 }