public async Task <IActionResult> UploadPdfReceipt(string id, IFormFile file) { PdfReceiptReader pdfReceiptReader = new PdfReceiptReader(file); var receipt = pdfReceiptReader.GetReceipt(); var financialQuery = new GetUsersFromFinancialProjectQuery() { FinancialProjectId = id }; var userDtos = await Mediator.Send(financialQuery); var createReceiptModel = new CreateReceiptModel { FinancialProjectId = id, CreateReceiptItemVm = await CreateReceiptItemVm(userDtos), ReceiptDto = new ReceiptDto() }; createReceiptModel.ReceiptDto.Location = receipt.Location; createReceiptModel.ReceiptDto.DateVisited = receipt.DateVisited; var model = new PdfReceiptVm { CreateReceiptModel = createReceiptModel, PdfReceiptDto = receipt }; return(View("CreateReceiptFromPdf", model)); }
public async Task <IActionResult> EditReceipt(string id, string financialProjectId) { var query = new GetReceiptByIdQuery { ReceiptId = id }; var receiptDto = await Mediator.Send(query); var usersQuery = new GetUsersFromFinancialProjectQuery { FinancialProjectId = financialProjectId }; var userDtos = await Mediator.Send(usersQuery); var model = new CreateReceiptModel { ReceiptDto = receiptDto, FinancialProjectId = financialProjectId, CreateReceiptItemVm = await CreateReceiptItemVm(userDtos) }; return(View(model)); }
public void Handle_WrongId_ShouldThrowNotFoundException() { var query = new GetUsersFromFinancialProjectQuery { FinancialProjectId = "asdasdas" }; FluentActions.Invoking(async() => await SendAsync(query)).Should().Throw <NotFoundException>(); }
public void Handle_NullId_ShouldThrowValidationException() { var query = new GetUsersFromFinancialProjectQuery { FinancialProjectId = null }; FluentActions.Invoking(async() => await SendAsync(query)).Should().Throw <ValidationException>(); }
public async Task <IActionResult> CreateReceipt(string id) { var financialQuery = new GetUsersFromFinancialProjectQuery() { FinancialProjectId = id }; var userDtos = await Mediator.Send(financialQuery); var model = new CreateReceiptModel { FinancialProjectId = id, CreateReceiptItemVm = await CreateReceiptItemVm(userDtos) }; return(View("CreateReceipt", model)); }
public async Task Handle_ValidId_ShouldReturnUsers() { var project = await CreateFinancialProject(); var query = new GetUsersFromFinancialProjectQuery { FinancialProjectId = project }; var model = await SendAsync(query); model.Should().NotBeNull(); model.Should().HaveCount(2); model.Should().OnlyHaveUniqueItems(x => x.Id); model.FirstOrDefault(x => x.Id == User.Id).Should().NotBeNull(); model.FirstOrDefault(x => x.Id == SecondUser.Id).Should().NotBeNull(); }
public async Task <IActionResult> CreateReceiptFromPdf(string id, PdfReceiptDto pdfReceiptDto) { var financialQuery = new GetUsersFromFinancialProjectQuery() { FinancialProjectId = id }; var userDtos = await Mediator.Send(financialQuery); var createReceiptModel = new CreateReceiptModel { FinancialProjectId = id, CreateReceiptItemVm = await CreateReceiptItemVm(userDtos) }; var model = new PdfReceiptVm { CreateReceiptModel = createReceiptModel, PdfReceiptDto = pdfReceiptDto }; return(View(model)); }