public async Task <bool> AddBid(Bid model) { int currentMaxBid; var bids = _repository.GetBidsAsync(model.AuktionID).Result; if (bids.Count() < 1) { var auction = await _auctionRepository.GetAuctionAsync(model.AuktionID); currentMaxBid = auction.Utropspris; } else { var maxBid = bids.Select(x => x.Summa).Max(); currentMaxBid = maxBid; } if (model.Summa > currentMaxBid) { return(await _repository.AddBid(model)); } else { return(false); } }
public ActionResult <Bid> CreateBid(Bid Bid) { //var BidEntity = _mapper.Map<Entities.Bid>(Bid); _BidRepository.AddBid(Bid); _BidRepository.Save(); //var BidReturn = _mapper.Map<BidDto>(BidEntity); return(CreatedAtRoute("GetBid", new { BidId = Bid.Id }, Bid)); }
public ActionResult AddBid(BidCreateDto Bid) { var userId = HttpContext.User.Identity.Name; Bid.UserId = Guid.Parse(userId); var result = _repository.AddBid(Bid); if (result != BidCode.Success) { return(BadRequest(result.GetDescription())); } return(Ok(new { message = result.GetDescription() })); }
public IActionResult Post([FromBody] Bid bid) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _BidRepository.AddBid(bid); try { _BidRepository.Save(); } catch { throw; } return(NoContent()); }
public IActionResult Add(Bid b) { repository.AddBid(b); return(RedirectToAction("Detail", "Listing", new { id = b.ListingId })); }
public async Task <ServiceResult> AddBid(Bid model) { return(await _bidRepository.AddBid(model)); }