public async Task <List <ClientDto> > GetAll(int userId) { // TODO: [TESTS] (ClientService.GetAll) Add tests var builder = new ServiceMetricBuilder(nameof(ClientService), nameof(GetAll)) .WithCategory(MetricCategory.Client, MetricSubCategory.GetAll) .WithCustomInt1(userId); try { using (builder.WithTiming()) { List <ClientEntity> dbClients; using (builder.WithCustomTiming1()) { builder.IncrementQueryCount(); dbClients = await _clientRepo.GetAll(userId); builder.WithResultsCount(dbClients?.Count ?? 0); } if (dbClients == null || dbClients.Count == 0) { return(new List <ClientDto>()); } return(dbClients .AsQueryable() .Select(ClientDto.Projection) .ToList()); } } catch (Exception ex) { _logger.LogUnexpectedException(ex); builder.WithException(ex); return(new List <ClientDto>()); } finally { await _metrics.SubmitPointAsync(builder.Build()); } }
public IActionResult List() { var clientVM = new List <CientViewModel>(); var cients = _clientRepo.GetAll(); if (cients.Count() == 0) { return(View("Empty")); } foreach (var client in cients) { clientVM.Add(new CientViewModel { Client = client, DvdCount = _dvdRepo.Count(x => x.ClientId == client.ClientId) }); } return(View(clientVM)); }
public List <Client> GetClients() { return(ClientRepo.GetAll().ToList()); }