public async Task <IActionResult> GetBuyer(int id) { var buyer = await repo.GetBuyer(id); var buyerToReturn = mapper.Map <BuyerToReturn>(buyer); return(Ok(buyerToReturn)); }
private DataAgent <decimal> CountTotalOrderBalance(List <ProductInOrderInputModel> products, long buyerId) { decimal totalCost = 0; var productSearchResult = new DataAgent <List <ProductDto> >(); foreach (var product in products) { productSearchResult = _productRepo.FindProducts(new ProductSearchDto { Id = product.ProductId }); if (!productSearchResult.ContainsData) { return(new DataAgent <decimal> { ResponseMessage = productSearchResult.ResponseMessage }); } totalCost += (decimal)productSearchResult.Data[0].Price; } var buyerDto = _buyerRepository.GetBuyer(buyerId); if (!buyerDto.ContainsData) { return(new DataAgent <decimal> { ResponseMessage = buyerDto.ResponseMessage }); } totalCost = totalCost - ((totalCost / 100) * (buyerDto.Data.BuyerStatus.Dicscount)); return(new DataAgent <decimal> { Data = totalCost }); }
public DataAgent <BuyerOutputModel> GetBuyer(long buyerId) { var dto = _buyerRepo.GetBuyer(buyerId); var result = new BuyerOutputModel(); if (dto.ContainsData) { result = _mapper.Map <BuyerOutputModel>(dto); } return(new DataAgent <BuyerOutputModel> { Data = result, ResponseMessage = dto.ResponseMessage }); }
public async Task <Result <Purchase> > SellTickets(SellTicketsRequest request) { var possibleConcert = await _concertRepository.GetConcert(request.ConcertId); var result = await possibleConcert .ToResult(Errors.ConcertNotFound) .OnFailure(error => PublishPurchaseFailure(request, "Unknown")) .Bind(async concert => { var possibleBuyer = await _buyerRepository.GetBuyer(request.BuyerId); return(await possibleBuyer .ToResult(Errors.BuyerNotFound) .Bind(buyer => _ticketsService.SellTickets(concert, buyer, new TicketQuantity(request.Quantity))) .Tap(purchase => PublishPurchaseSuccess(purchase)) .OnFailure(error => PublishPurchaseFailure(request, concert.Name))); }); return(result); }
public IActionResult Details(string buyerId) { var buyer = buyerRepository.GetBuyer(buyerId); return(View(buyer)); }
public IActionResult Index() { var objBuyer = _BuyerRepository.GetBuyer(); return(View(objBuyer)); }