Пример #1
0
        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);
            }
        }
Пример #2
0
        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));
        }
Пример #3
0
        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() }));
        }
Пример #4
0
        public IActionResult Post([FromBody] Bid bid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _BidRepository.AddBid(bid);
            try
            {
                _BidRepository.Save();
            }
            catch
            {
                throw;
            }
            return(NoContent());
        }
Пример #5
0
 public IActionResult Add(Bid b)
 {
     repository.AddBid(b);
     return(RedirectToAction("Detail", "Listing", new { id = b.ListingId }));
 }
Пример #6
0
 public async Task <ServiceResult> AddBid(Bid model)
 {
     return(await _bidRepository.AddBid(model));
 }