Ejemplo n.º 1
0
        public async Task <List <CustomerViewModel> > GetCustomerBySupportRepIdAsync(int id,
                                                                                     CancellationToken ct = default(CancellationToken))
        {
            var customers = await _customerRepository.GetBySupportRepIdAsync(id, ct);

            return(CustomerCoverter.ConvertList(customers).ToList());
        }
Ejemplo n.º 2
0
        public async Task <List <CustomerViewModel> > GetAllCustomerAsync(
            CancellationToken ct = default(CancellationToken))
        {
            var customers = CustomerCoverter.ConvertList(await _customerRepository.GetAllAsync(ct)).ToList();

            return(customers);
        }
Ejemplo n.º 3
0
        public async Task <CustomerViewModel> GetCustomerByIdAsync(int id, CancellationToken ct = default(CancellationToken))
        {
            var customerViewModel = CustomerCoverter.Convert(await _customerRepository.GetByIdAsync(id, ct));

            customerViewModel.Invoices = await GetInvoiceByCustomerIdAsync(customerViewModel.CustomerId, ct);

            customerViewModel.SupportRep = await GetEmployeeByIdAsync(customerViewModel.SupportRepId.GetValueOrDefault(), ct);

            customerViewModel.SupportRepName = $"{customerViewModel.SupportRep.LastName}, {customerViewModel.SupportRep.FirstName}";
            return(customerViewModel);
        }
Ejemplo n.º 4
0
        public async Task <List <CustomerViewModel> > GetAllCustomerAsync(CancellationToken ct = default(CancellationToken))
        {
            var customers = CustomerCoverter.ConvertList(await _customerRepository.GetAllAsync(ct)).ToList();

            foreach (var customer in customers)
            {
                customer.Invoices = await GetInvoiceByCustomerIdAsync(customer.CustomerId, ct);

                customer.SupportRep = await GetEmployeeByIdAsync(customer.SupportRepId.GetValueOrDefault(), ct);

                customer.SupportRepName = $"{customer.SupportRep.LastName}, {customer.SupportRep.FirstName}";
            }
            return(customers.ToList());
        }