public async Task <IHttpActionResult> AcceptBuyTransaction([FromBody] TransactionDto dto) { if (ModelState.IsValid == false) { return(BadRequest("Invalid data")); } if (dto.SellOffer.SellerId != (Thread.CurrentPrincipal as UserPrincipal).Id) { return(Unauthorized()); } var sellOffer = _sellAssembler.DtoToEntity(dto.SellOffer); var buyOffer = _buyAssembler.DtoToEntity(dto.BuyOffer); var rating = dto.Rating; var result = await _transactionService.AcceptBuyTransaction(sellOffer, buyOffer, rating); if (result == ErrorValue.AmountGreaterThanStock) { return(BadRequest("Amount greater than stock")); } else if (result == ErrorValue.ServerError) { return(BadRequest("Transaction error")); } return(Ok()); }