public Task <IServiceResult <Error, Rate[]> > GetRatesAsync(int year, int month, string[] currencyCodes) { return(RunAsync(async() => { if (year < 1990 || year > DateTime.UtcNow.Year) { return ServiceResult <Error, Rate[]> .Fault(null, BlErrors.Error1003(nameof(year), year.ToString())); } if (month < 1 || month > 12) { return ServiceResult <Error, Rate[]> .Fault(null, BlErrors.Error1003(nameof(month), month.ToString())); } var rates = await _unitOfWork.RateRepository.GetEntitiesAsync(Specifications.MonthRate(year, month, currencyCodes)); return ServiceResult <Error> .Success(rates.ToArray()); })); }
public Task <ActionResult> Get(int year, int month, string type) { if (string.IsNullOrEmpty(type)) { return(Task.FromResult(FaultedActionResult(BlErrors.Error1002(nameof(type))))); } var lowerType = type.ToLower(); if (lowerType == REPORT_TYPE_TXT) { return(ActionResultAsync(_rateService.GetTxtReportAsync(year, month))); } else if (lowerType == REPORT_TYPE_JSON) { return(ActionResultAsync(_rateService.GetReportAsync(year, month))); } return(Task.FromResult(FaultedActionResult(ApiErrors.Error2001(type)))); }