示例#1
0
        public async Task <GetPaymentMethodForViewDto> GetPaymentMethodForView(int id)
        {
            var paymentMethod = await _paymentMethodRepository.GetAsync(id);

            var output = new GetPaymentMethodForViewDto {
                PaymentMethod = ObjectMapper.Map <PaymentMethodDto>(paymentMethod)
            };

            return(output);
        }
示例#2
0
        public async Task <PagedResultDto <GetPaymentMethodForViewDto> > GetAll(GetAllPaymentMethodsInput input)
        {
            var filteredPaymentMethods = _paymentMethodRepository.GetAll()
                                         .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.Name.Contains(input.Filter) || e.Code.Contains(input.Filter));

            var pagedAndFilteredPaymentMethods = filteredPaymentMethods
                                                 .OrderBy(input.Sorting ?? "id asc")
                                                 .PageBy(input);

            var paymentMethods = from o in pagedAndFilteredPaymentMethods
                                 select new
            {
                Id = o.Id
            };

            var totalCount = await filteredPaymentMethods.CountAsync();

            var dbList = await paymentMethods.ToListAsync();

            var results = new List <GetPaymentMethodForViewDto>();

            foreach (var o in dbList)
            {
                var res = new GetPaymentMethodForViewDto()
                {
                    PaymentMethod = new PaymentMethodDto
                    {
                        Id = o.Id,
                    }
                };

                results.Add(res);
            }

            return(new PagedResultDto <GetPaymentMethodForViewDto>(
                       totalCount,
                       results
                       ));
        }