public async Task <IActionResult> Export(EstimationDto estimationDto) { using (MemoryStream stream = new System.IO.MemoryStream()) { string fileName = "estimation.cshtml"; string directory = _config["StoredFilesPath"]; string url = string.Format("{0}://{1}/{2}/{3}", HttpContext.Request.Scheme, HttpContext.Request.Host.Value, directory, fileName); var filePath = Path.Combine(new string[] { Directory.GetCurrentDirectory(), directory, fileName }); string value = System.IO.File.ReadAllText(filePath); value = value.Replace("[#GoldPrice#]", string.Format("{0}", estimationDto.GoldPrice)); value = value.Replace("[#Weight#]", string.Format("{0}", estimationDto.Weight)); value = value.Replace("[#TotalPrice#]", string.Format("{0}", estimationDto.TotalPrice)); value = value.Replace("[#Discount#]", string.Format("{0}", estimationDto.Discount)); return(await _generatePdf.GetPdfViewInHtml(value)); } }
public async Task GetEstimationAsync_Should_Return_Cached_Estimation() { // arrange var estimationId = Guid.NewGuid().ToString(); var estimation = new EstimationDto { EstimationId = estimationId }; var json = EstimationDto.ToString(estimation); _mockEstimationRepository.GetEstimationAsync(estimationId) .Returns(json); // act var result = await _service.GetEstimationAsync(estimationId); // assert Assert.IsNotNull(result); Assert.AreEqual(estimationId, result.EstimationId); }
public async Task CreateEstimationAsync_Should_Save_The_Estimation() { // arrange _mockCountryService.IsSupportedCountryAsync("US", "IN", _cxlToken) .Returns(Task.FromResult(true)); _mockPaymentService.TransactionRangeAsync("US") .Returns(Task.FromResult(new TransactionAmount { MinAmount = 500, MaxAmount = 1000 })); //_mockTaxAndFeeService.GetFeeAsync("US", "IN", 600, _cxlToken) // .Returns(Task.FromResult(new List<FeeDto>())); _mockExchangeService.GetExchangeRateAsync("US", "IN", _cxlToken) .Returns(1); // act var result = await _service.CreateEstimationAsync("US", "IN", 600, _cxlToken); await _mockEstimationRepository .Received(1) .SaveEstimationAsync(result.EstimationId, EstimationDto.ToString(result)); }
private static Estimation FromDto(EstimationDto e) { return(new Estimation(e.Value, e.Player, e.Timestamp)); }