Пример #1
0
        public async Task <IActionResult> GetSpecific(long sinumber, DateTime warrantyRequestDate)
        {
            var response = await _service.GetPaymentsAsync(new GetPaymentsRequest()
            {
                SiNumber = sinumber, ReferenceDate = warrantyRequestDate
            });

            if (response.BusinessMessages != null && response.BusinessMessages.Length > 0)
            {
                return(BadRequest(response.BusinessMessages));
            }

            var mappedModel = _mapper.Map <IEnumerable <ZvzPayment> >(response.Value?.Payments);

            return(Ok(mappedModel));
        }
Пример #2
0
        private async Task <decimal> GetCurrentPaymentAmount(long siNumber, DateTime reference)
        {
            var response = await _zvzService.GetPaymentsAsync(new GetPaymentsRequest()
            {
                SiNumber = siNumber, ReferenceDate = reference
            });

            if (response.Value != null && response.Value.Payments != null && response.Value.Payments.Count() > 0)
            {
                return(response.Value.Payments.OrderByDescending(p => p.PeriodEnd).FirstOrDefault().Amount);
            }
            else if (response.BusinessMessages != null && response.BusinessMessages.Any())
            {
                var errors = response.BusinessMessages.Where(bm => bm.Type == MessageType.Error);
                if (errors.Any())
                {
                    throw new Exception(string.Join("; ", errors.Select(e => e.MessageString)));
                }
            }
            return(0);
        }