示例#1
0
        public Offer GetOffer(BidDto bid)
        {
            var offer = new Offer();

            offer.OfferedPrice = bid.OfferedPrice;
            offer.Bidder       = new Human();
            offer.Bidder.Email = bid.Bidder.Email;

            var names = bid.Bidder.FullName.Split(' ');

            offer.Bidder.FirstName = names[0];
            offer.Bidder.LastName  = names[1];

            offer.House         = new House();
            offer.House.Address = new Address();


            offer.House.Address.City         = bid.Offer.City;
            offer.House.Address.StreetName   = bid.Offer.StreetName;
            offer.House.Address.StreetNumber = bid.Offer.StreetNumber;

            offer.House.Price = bid.Offer.Price;

            return(offer);
        }
示例#2
0
        public void Update(BidDto bid)
        {
            var orm = _bidRepository.GetById(bid.BidId);

            orm = bid.ToDal(orm);
            _bidRepository.Update(orm);
        }
示例#3
0
        public async Task <IActionResult> MakeBid([FromBody] BidDto bid)
        {
            var lot = _lotsService.GetItem(bid.LotId);

            if (lot == null)
            {
                return(BadRequest());
            }
            var user = _usersServices.GetItem(UserId);

            if (lot.Price >= bid.Price)
            {
                ModelState.AddModelError(nameof(bid.Price), "Bid must be greater than value price");
            }
            if (user.Money < bid.Price)
            {
                ModelState.AddModelError(nameof(bid.Price), "Not enough funds");
            }
            if (ModelState.IsValid)
            {
                _usersServices.MakeBid(lot.LotId, UserId, bid.Price);
                var lastbid  = _bidsService.GetLastBidForLot(bid.LotId);
                var row_info = string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr", lastbid.User.UserName,
                                             lastbid.Price.ToString("C"), lastbid.DateOfBid.ToString("f"));
                await _hubcontext.Clients.All.SendAsync("BidMade",
                                                        lot.LotId, row_info, lastbid.Price.ToString("C"));

                return(Ok());
                //return new ObjectResult(new {row = row_info});
            }
            return(new BadRequestObjectResult(ModelState));
        }
示例#4
0
        public ResponseModel AddBid(BidDto bid)
        {
            _ = bid ?? throw new ArgumentNullException($"{nameof(bid)} null object detected");
            ResponseModel response = new ResponseModel();

            if (bid.Amount == null || bid.CustomerId == default(Guid))
            {
                response.Message = "Invalid Bid";
                response.Status  = false; return(response);
            }

            if (bid.Amount.CurrencyType != AmountNeeded.CurrencyType)
            {
                response.Message = "Not expected currency";
                response.Status  = false;
                return(response);
            }

            if (HasReachedBiddingLimit())
            {
                response.Message = "Bidding limit has been reached";
                response.Status  = false;
                return(response);
            }

            _bids.Add(Bid.AddBid(Id, bid));
            response.Status  = true;
            response.Message = "Bid has been added successfully";
            return(response);
        }
        public async Task MakeBidToAuction(BidDto bid)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                await _bidService.PlaceBid(bid);

                await uow.Commit();
            }
        }
示例#6
0
        internal static Bid AddBid(Guid listingId, BidDto bidDto)
        {
            // Add checks to ensure amount is not 0

            return(new Bid
            {
                Amount = bidDto.Amount,
                CustomerId = bidDto.CustomerId
            });
        }
示例#7
0
        public IHttpActionResult Create(int id, BidDto bidDto)
        {
            var auction = service.GetAll().FirstOrDefault(a => a.Id == id);

            if (auction == null)
            {
                return(BadRequest($"No auction with id {id} found"));
            }
            service.PlaceBid(auction, bidDto.Amount);
            return(Ok());
        }
        public async Task BuyoutAuction(AuctionDto auction, BidDto bid)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                await _bidService.PlaceBid(bid);

                await uow.Commit();

                var auctionBids = await _bidService.GetBidsAccordingToAuctionAsync(auction.Id);

                _closingAuctionService.CloseAuctionDueToBuyout(auction, auctionBids);
                await uow.Commit();
            }
        }
        public async Task <ActionResult> Buyout(AuctionDetailViewModel model)
        {
            var auction = await AuctionProcessFacade.GetAuctionAsync(model.Auction.Id);

            var bid = new BidDto
            {
                AuctionId    = auction.Id,
                BuyerId      = (await UserFacade.GetUserAccordingToUsernameAsync(User.Identity.Name)).Id,
                BidAmount    = auction.BuyoutPrice - auction.ActualPrice,
                NewItemPrice = auction.BuyoutPrice,
                Time         = DateTime.Now
            };
            await AuctionProcessFacade.BuyoutAuction(auction, bid);

            return(RedirectToAction("Index"));
        }
示例#10
0
        public IHttpActionResult PlaceBid(long auctionId, BidDto dto)
        {
            var auction = this.repo.GetAuctions().FirstOrDefault(a => a.Id == auctionId);

            if (auction == null)
            {
                return(this.NotFound());
            }

            try
            {
                var bid = this.auctionService.PlaceBid(auction, dto.Amount);

                AuctionsHub.NotifyNewBid(auction, bid);

                return(this.Created(string.Format("api/bids/{0}", bid.TransactionId), MapBidToDto(bid)));
            }
            catch (Exception e)
            {
                return(this.BadRequest(e.Message));
            }
        }
示例#11
0
 public BidDto AddItem(BidDto bid)
 {
     return(_bidRepository.Create(bid.ToDal()).ToDto());
 }
示例#12
0
 public static Bid ToDal(this BidDto dto, Bid orm) => Mapper.Map(dto, orm);
示例#13
0
 public static Bid ToDal(this BidDto dto) => Mapper.Map <Bid>(dto);
示例#14
0
        static void Main(string[] args)
        {
            var address = new Address
            {
                City         = "Warsaw",
                Country      = "Poland",
                StreetName   = "Marszałkowska",
                StreetNumber = "10"
            };

            var owner = new Human
            {
                Age         = 30,
                Description = "Seems like he want's to buy.",
                Email       = "*****@*****.**",
                FirstName   = "Jan",
                LastName    = "Kowalski"
            };

            var seller = new Human
            {
                Age       = 52,
                Email     = "*****@*****.**",
                FirstName = "Marian",
                LastName  = "Maliniak"
            };

            var house = new House
            {
                Area        = 82.4f,
                Description = "Nice, sunny appartment in center of Warsaw.",
                Rooms       = 4,
                HasGarrage  = false,
                Levels      = 1,
                Price       = 600000f
            };

            var propertyService = new PropertyService();
            var property        = propertyService.CreateProperty(owner, seller, house, address);
            var gradkaService   = new GratkaService();



            var humanService  = new HumanServicec();
            var sellerDetails = humanService.CreateNewUserDetails(seller, BLL.Dtos.Role.SELLER);
            var ownerDetails  = humanService.CreateNewUserDetails(owner, BLL.Dtos.Role.OWNER);

            var offer  = gradkaService.CreateOffer(property, ownerDetails, sellerDetails);
            var isSent = gradkaService.Send(offer);

            if (isSent == true)
            {
                System.Console.WriteLine("We are send the offer");
            }
            else
            {
                System.Console.WriteLine("We did not sent the offer");
            }

            System.Console.WriteLine(offer.City);
            System.Console.WriteLine($"Owner detail is {ownerDetails.FullName}.");
            System.Console.WriteLine($"Seller detail is {sellerDetails.FullName}.");


            var bidDto = new BidDto();

            bidDto.OfferedPrice = 700000;

            bidDto.Bidder          = new UserDetailsDto();
            bidDto.Bidder.Email    = "*****@*****.**";
            bidDto.Bidder.FullName = "Jan Kowalski";
            bidDto.Bidder.Role     = Role.UNDEFINED;

            bidDto.Offer              = new GratkaOfferDto();
            bidDto.Offer.City         = "Gdansk";
            bidDto.Offer.Price        = 650000;
            bidDto.Offer.StreetName   = "Warszawska";
            bidDto.Offer.StreetNumber = "22";


            var bidService  = new BidService();
            var clientOffer = bidService.GetOffer(bidDto);

            System.Console.WriteLine($"Dom na sprzedaz jest w miescie {clientOffer.House.Address.City}");
        }
示例#15
0
 public static BidViewModel ToVm(this BidDto dto) => Mapper.Map <BidViewModel>(dto);
示例#16
0
        public void Add(BidDto bidDto)
        {
            var bid = new Bid(bidDto.Name);

            _repository.Add(bid);
        }
示例#17
0
 public void Post([FromBody] BidDto dto)
 {
     _bidService.Add(dto);
 }
        public async Task <IActionResult> BidOnItem(Guid itemId, [FromBody] BidDto dto)
        {
            await this.auctionService.BidOnItemAsync(itemId, dto.Value, this.GetUserId());

            return(NoContent());
        }