public Bid PlaceBid(Auction auction, double amount) { var auct = this.mainRepository.GetAuctions().ToList().FirstOrDefault(a => a.Id == auction.Id && a == auction); var bidder = this.memberService.GetCurrentMember(); if (auct == null) { throw new MissingAuctionException("This auction does not exist in the store"); } if (auct.StartDateTimeUtc > DateTime.UtcNow) { throw new AuctionStateException("The requested auction has not started yet"); } if (auct.EndDateTimeUtc <= DateTime.UtcNow) { throw new AuctionStateException("The requested auction has already closed"); } var bid = new Bid() { ReceivedOnUtc = DateTime.UtcNow, Accepted = null, Auction = auct, Amount = amount, Bidder = bidder }; this.mainRepository.Add(bid); this.mainRepository.SaveChanges(); return bid; }
public GameScore(Bid gameBid,int nsScore,int ewScore) { this.GameBid = gameBid; Score = new Dictionary<TeamPosition, int>(); Score[TeamPosition.NorthSouth] = nsScore; Score[TeamPosition.EastWest] = ewScore; }
public void PlaceBid_WhenInvokedAmountLowerThanMinimum_ArgumentExceptionIsThrown() { var auction = new Auction(_dummyItem, _dummyGuid, 20); var bid = new Bid(Guid.NewGuid(), 10); Assert.Throws<ArgumentException>(() => { auction.PlaceBid(bid); }); }
private Action<BidPlaced> BidPlaced() { return (BidPlaced e) => { var bidEvent = new Bid(e.AuctionId, e.Bidder, e.AmountBid, e.TimeOfBid); _bidHistory.Add(bidEvent); }; }
public void Save(Bid bid) { DAL.Bid pd = new DAL.Bid(); pd.BidderId = bid.User.Id; pd.AuctionId = bid.AuctionId; pd.Amount = bid.Amount; db.Bids.InsertOnSubmit(pd); db.SubmitChanges(); }
public void Ctor_WhenInvokedWithCorrectValues_PropertiesAreSet() { uint amount = 5; var expectedTime = DateTime.Now; var bid = new Bid(_dummyGuid, amount); Assert.AreEqual(_dummyGuid, bid.UserId); Assert.AreEqual(amount, bid.Amount); Assert.GreaterOrEqual(expectedTime, bid.Time); }
public void Add(Bid bid) { var bidDTO = new BidDTO(); bidDTO.AuctionId = bid.AuctionId; bidDTO.Bid = bid.AmountBid.GetSnapshot().Value; bidDTO.BidderId = bid.Bidder; bidDTO.TimeOfBid = bid.TimeOfBid; bidDTO.Id = Guid.NewGuid(); _auctionExampleContext.Bids.Add(bidDTO); }
public void GetCurrentPrice_WhenTwoBidsExist_HighestAmountIsReturned() { var auction = new Auction(_dummyItem, _dummyGuid, 1); var bid1 = new Bid(Guid.NewGuid(), 2); auction.PlaceBid(bid1); var bid2 = new Bid(Guid.NewGuid(), 3); auction.PlaceBid(bid2); uint currentPrice = auction.GetCurrentPrice(); Assert.AreEqual(bid2.Amount, currentPrice); }
public Response<Bid> CreateBid(decimal amount, User objUser) { var response = new Response<Bid>(); if (response.Success) { var bid = new Bid(); bid.Amount = amount; _repository.Save(bid); response.Entity = bid; } return response; }
public Response<Bid> UpdateBidDetail(int id, decimal amount) { var response = new Response<Bid>(); if (response.Success) { var product = new Bid(); product.Id = id; product.Amount = amount; _repository.UpdateBid(product); } return response; }
private Bid Parse(string data) { Bid bid = null; bid = new Bid(); string[] item = data.Split(new Char[] { ':', ',' }); if (item[9].Length != 8) return null; string exchange = item[11].Substring(1, 4); string code = item[9].Substring(1, 6); if (exchange == "XSHG") bid.Code = "sh" + item[9].Substring(1, 6); else // if (exchange == "XSHE") bid.Code = "sz" + item[9].Substring(1, 6); //if (!bid.Code.StartsWith("sz150") && !bid.Code.StartsWith("sh502") && // !bid.Code.StartsWith("sh000") && !bid.Code.StartsWith("sz399")) // return null; bid.CurrentPrice = float.Parse(item[53]); bid.High = float.Parse(item[57]); bid.Open = float.Parse(item[55]); bid.Low = float.Parse(item[59]); bid.LastClose = float.Parse(item[61]); bid.PushTime = new DateTime(long.Parse(item[63])).ToString(); bid.Name = item[7].Substring(1,item[7].Length-2); bid.Volumn = long.Parse(item[5]); bid.Turnover = float.Parse(item[3]); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(item[13]), int.Parse(item[23]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(item[15]), int.Parse(item[25]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(item[17]), int.Parse(item[27]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(item[19]), int.Parse(item[29]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(item[21]), int.Parse(item[31]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(item[33]), int.Parse(item[43]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(item[35]), int.Parse(item[45]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(item[37]), int.Parse(item[47]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(item[39]), int.Parse(item[49]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(item[41]), int.Parse(item[51]))); return bid; }
protected override Message CreateReply() { AuctionAnnouncement auction = Request as AuctionAnnouncement; Bid bid = null; if (auction.MinimumBid <= ((Player)Process).Pennies.Count) { pennies = new Penny[auction.MinimumBid]; ((Player)Process).Pennies.TryPopRange(pennies); bid = new Bid() { Pennies = pennies, Success = true }; } else bid = new Bid() { Success = false }; return bid; }
public Bid Get(int id) { var pt = db.Bids.Where(x => x.Id == id).FirstOrDefault(); if (pt != null) { Bid pd = new Bid(); pd.Id = pt.Id; pd.Amount = pt.Amount.HasValue ? pt.Amount.Value : 0; DAL.User user = db.Users.Where(x => x.Id == pt.BidderId).FirstOrDefault(); if (user != null) { pd.User = new User(); pd.User.Email = user.Email; pd.User.Password = user.Password; pd.User.Address = user.Address; DAL.Bank b = db.Banks.Where(x => x.Id == user.BankDetailId).FirstOrDefault(); if (b != null) { pd.User.BankDetails = new Bank(); pd.User.BankDetails.Id = b.Id; pd.User.BankDetails.AccountNumber = b.AccountNbr; pd.User.BankDetails.Balance = b.Balance.HasValue ? b.Balance.Value : 0; } } pd.AuctionId = pt.AuctionId.HasValue ? pt.AuctionId.Value : 0; return pd; } return null; }
protected internal void DoomThisConnection() { this._connectionIsDoomed = true; Bid.PoolerTrace("<prov.DbConnectionInternal.DoomThisConnection|RES|INFO|CPOOL> %d#, Dooming\n", this.ObjectID); }
public PartialBid(Bid bid) { bidder = bid.bidder; amount = bid.amount; created = bid.created; }
public bool AddBid(Bid bid) { _context.Entry(bid).State = EntityState.Added; return(_context.SaveChanges() > 0); }
public void GivenARepoWithAuctionAndMember_AddBid_AuctionIsReferencedFromBidder() { var theSeller = CreateAMember(); var createdAuction = CreateAnAuction(); // References createdAuction.Seller = theSeller; var theBidder = CreateAMember(); var bid = new Bid() { Auction = createdAuction, Bidder = theBidder, Amount = 12 }; List<Member> allMembersFromRepo; using (var factory = this.CreateFactory()) { var testRepo = factory.CreateMainRepository(); testRepo.Add(createdAuction); testRepo.Add(theBidder); testRepo.Add(bid); testRepo.SaveChanges(); allMembersFromRepo = testRepo.GetMembers().ToList(); } // Sanity check Assert.AreEqual(2, allMembersFromRepo.Count()); // Take the bidder to test var bidderMember = allMembersFromRepo.FirstOrDefault(b => b.UniqueId == theBidder.UniqueId); Assert.IsNotNull(bidderMember); Assert.IsNotNull(bidderMember.Bids); Assert.AreEqual(1, bidderMember.Bids.Count); Assert.AreEqual(bid, bidderMember.Bids.First()); }
public void PlaceBid(Bid newbid) { var returnBid = _service.PlaceBid(newbid); if (returnBid != null) Clients.All.receiveBid(returnBid); }
private Bid Parse(string data) { String[] items = data.Split(new char[] { ',' }); if (items.Length < 10) return null; Bid bid = new Bid(); bid.Code = data.Substring(11, 8); bid.Name = items[0].Substring(21, items[0].Length-21); // var hq_str_sz150023="深成指B bid.Open = float.Parse(items[1]); bid.LastClose = float.Parse(items[2]); bid.CurrentPrice = float.Parse(items[3]); bid.High = float.Parse(items[4]); bid.Low = float.Parse(items[5]); //bid.Buy = decimal.Parse(items[6]); //bid.Sell = decimal.Parse(items[7]); bid.Volumn = long.Parse(items[8]); bid.Turnover = float.Parse(items[9]); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(items[BUY_1_P]), int.Parse(items[BUY_1_A]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(items[BUY_2_P]), int.Parse(items[BUY_2_A]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(items[BUY_3_P]), int.Parse(items[BUY_3_A]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(items[BUY_4_P]), int.Parse(items[BUY_4_A]))); bid.AddBuyGoodsData(new Bid.GoodsData(float.Parse(items[BUY_5_P]), int.Parse(items[BUY_5_A]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(items[SELL_1_P]), int.Parse(items[SELL_1_A]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(items[SELL_2_P]), int.Parse(items[SELL_2_A]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(items[SELL_3_P]), int.Parse(items[SELL_3_A]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(items[SELL_4_P]), int.Parse(items[SELL_4_A]))); bid.AddSellGoodsData(new Bid.GoodsData(float.Parse(items[SELL_5_P]), int.Parse(items[SELL_5_A]))); return bid; }
internal void method_7(Bid bid_0) { if (this.strategy__0 != null && this.Status == StrategyStatus.Running) { List<Strategy> list; if (this.Mode == StrategyMode.Backtest) { list = this.idArray_2[bid_0.instrumentId]; } else { list = this.idArray_3[bid_0.instrumentId][(int)bid_0.providerId]; } for (int i = 0; i < list.Count; i++) { list[i].vmethod_10(bid_0); } } }
public virtual Bid PlaceBid(Guid bidderId, decimal bidAmount) { if (CurrentBid != null && CurrentBid.Amount >= bidAmount) throw new ArgumentException( string.Format( "New bids must be higher than current maximum bid of {0}", CurrentBid.Amount)); var bid = new Bid {Amount = bidAmount, Auction = this, Bidder = new Bidder(bidderId)}; _bids.Add(bid); return bid; }
public void ProcessMarketData(DepthMarketDataField field) { if (field == null) { return; } if (_provider.EnableMarketLog) { //_provider.Logger.Debug($"{field.InstrumentID},{field.UpdateTime},{field.Bids[0].Price},{field.Bids[0].Size},{field.Asks[0].Price},{field.Asks[0].Size},{field.LastPrice},{field.Volume}."); _provider.Logger.Debug($"{field.InstrumentID},{field.UpdateTime},{field.LastPrice},{field.Volume}."); } _instDictCache.TryGetValue(field.InstrumentID, out var inst); if (inst == null) { if (_provider.EnableMarketLog) { _provider.Logger.Debug($"unsubscribed tick: {field.InstrumentID}."); } return; } var instId = inst.Id; var localTime = DateTime.Now; var exchangeTime = field.ExchangeDateTime(); if (exchangeTime.Year == DateTime.MaxValue.Year) { if (_provider.EnableMarketLog) { _provider.Logger.Debug($"empty trading time, {field.InstrumentID}"); } exchangeTime = localTime; } else { if (_provider.NightTradingTimeCorrection) { exchangeTime = QBHelper.CorrectionActionDay(localTime, exchangeTime); } } var time = exchangeTime.TimeOfDay; if (_provider.MaxTimeDiffExchangeLocal > 0) { var diff = Math.Abs((localTime.TimeOfDay - time).TotalMinutes); if (diff > _provider.MaxTimeDiffExchangeLocal) { if (_provider.EnableMarketLog) { _provider.Logger.Debug($"time diff ={diff},{field.InstrumentID}"); } return; } } var range = _timeRanges[instId]; if (!_instOpenFlag[instId]) { if (range.InRange(time)) { if (_instCloseFlag[instId] && range.IsClose(time)) { if (_provider.EnableMarketLog) { _provider.Logger.Debug($"already closed, {field.InstrumentID}."); } return; } inst.SetMarketData(field); _instOpenFlag[instId] = true; _instCloseFlag[instId] = false; if (_provider.EnableMarketLog) { _provider.Logger.Debug($"market open, {field.InstrumentID}."); } } else { if (_provider.EnableMarketLog) { _provider.Logger.Debug($"market no open, {field.InstrumentID}."); } return; } } var last = _marketData[instId]; if (range.IsClose(time) && field.ClosePrice > 0) { inst.SetMarketData(field); _instCloseFlag[instId] = true; _instOpenFlag[instId] = false; _marketData[instId] = EmptyMarketData; if (_provider.EnableMarketLog) { _provider.Logger.Debug($"market close, {field.InstrumentID}."); } } else { if (_czceInstFlag[inst.Id]) { field.ClosePrice = 0; } _marketData[instId] = field; } if (field.Asks?.Length > 0 && field.Asks[0].Size > 0) { #if Compatibility var ask = OpenQuant.Helper.NewTick <Ask>(localTime, exchangeTime, _provider.Id, instId, field.Asks[0].Price, field.Asks[0].Size); #else var ask = new Ask(localTime, exchangeTime, _provider.Id, instId, field.Asks[0].Price, field.Asks[0].Size); #endif _provider.ProcessMarketData(ask); } if (field.Bids?.Length > 0 && field.Bids[0].Size > 0) { #if Compatibility var bid = OpenQuant.Helper.NewTick <Bid>(localTime, exchangeTime, _provider.Id, instId, field.Bids[0].Price, field.Bids[0].Size); #else var bid = new Bid(localTime, exchangeTime, _provider.Id, instId, field.Bids[0].Price, field.Bids[0].Size); #endif _provider.ProcessMarketData(bid); } if (!(field.LastPrice > double.Epsilon)) { if (_provider.EnableMarketLog) { _provider.Logger.Debug($"empty price, {field.InstrumentID}."); } return; } var size = _provider.VolumeIsAccumulated ? field.Volume - last.Volume : field.Volume; if (_provider.DiscardEmptyTrade && _provider.VolumeIsAccumulated && Math.Abs(size) < double.Epsilon && _instOpenFlag[instId]) { if (_provider.EnableMarketLog) { _provider.Logger.Debug($"empty trade, {field.InstrumentID}."); } return; } #if Compatibility var trade = OpenQuant.Helper.NewTick <Trade>(localTime, exchangeTime, _provider.Id, instId, field.LastPrice, size); #else var trade = new Trade(localTime, exchangeTime, _provider.Id, instId, field.LastPrice, (int)size); #endif var turnover = double.NaN; if (_provider.VolumeIsAccumulated) { if (field.Turnover > last.Turnover) { turnover = field.Turnover - last.Turnover; } else { turnover = (field.Turnover / field.Volume) * size; } } else { turnover = field.Turnover; } if (!_czceInstFlag[instId]) { turnover /= inst.Factor; } trade.SetMarketData(field); trade.SetMarketData(turnover, field.OpenInterest); _provider.ProcessMarketData(trade); }
private Bid Parse() { Bid bid = new Bid(); return bid; }
private bool IsLargerThanLargestBid(double currentBidderPrice, double bidderAdjustment, Bid largestBid) { var currentLargestBidderPrice = largestBid.Price + (largestBid.Price * bidderAdjustment); return(currentBidderPrice > currentLargestBidderPrice); }
private void ThrowForInvalidReferences(Bid bid) { ThrowIfReferenceNotFound(bid, x => x.Auction, this.loadedData.Auctions, r => r.Id); ThrowIfReferenceNotFound(bid, x => x.Bidder, this.loadedData.Members, r => r.UniqueId); }
public void GivenARepoWithAuctionAndMember_AddBid_CanBeRetrievedByTransactionId() { var theSeller = CreateAMember(); var createdAuction = CreateAnAuction(); // References createdAuction.Seller = theSeller; var theBidder = CreateAMember(); var bid = new Bid() { Auction = createdAuction, Bidder = theBidder, Amount = 12 }; Bid retrievedBid; using (var factory = this.CreateFactory()) { var testRepo = factory.CreateMainRepository(); testRepo.Add(theBidder); testRepo.Add(createdAuction); testRepo.Add(bid); testRepo.SaveChanges(); retrievedBid = testRepo.GetBidByTransactionId(bid.TransactionId); } Assert.IsNotNull(retrievedBid); Assert.AreEqual(bid, retrievedBid); }
public void GivenARepoWithAuctionAndMember_AddBid_BidGetsListedInAuction() { var theSeller = CreateAMember(); var createdAuction = CreateAnAuction(); // References createdAuction.Seller = theSeller; var theBidder = CreateAMember(); var bid = new Bid() { Auction = createdAuction, Bidder = theBidder, Amount = 12 }; List<Auction> allAuctionsFromRepo; using (var factory = this.CreateFactory()) { var testRepo = factory.CreateMainRepository(); testRepo.Add(createdAuction); testRepo.Add(theBidder); testRepo.Add(bid); testRepo.SaveChanges(); allAuctionsFromRepo = testRepo.GetAuctions().ToList(); } // Sanity check Assert.AreEqual(1, allAuctionsFromRepo.Count()); Assert.IsNotNull(allAuctionsFromRepo[0].Bids); Assert.AreEqual(1, allAuctionsFromRepo[0].Bids.Count); Assert.AreEqual(bid, allAuctionsFromRepo[0].Bids.First()); }
internal void ActivateConnection(Transaction transaction) { Bid.PoolerTrace("<prov.DbConnectionInternal.ActivateConnection|RES|INFO|CPOOL> %d#, Activating\n", this.ObjectID); this.Activate(transaction); this.PerformanceCounters.NumberOfActiveConnections.Increment(); }
public IActionResult Add(Bid b) { repository.AddBid(b); return(RedirectToAction("Detail", "Listing", new { id = b.ListingId })); }
public virtual void OnBid(Bid bid) { // noop }
public void ProWin(Bid bidder) { var context = new SidejobEntities(); var professionalwinbid = new ProfessionalWinBid { BidID = bidder.BidID, ProID = bidder.BidderID, NumberofBids = GetProfessionalNumberofBids(bidder.BidderID) }; context.AddToProfessionalWinBids(professionalwinbid); context.DeleteObject(bidder); context.SaveChanges(); }
public IHttpActionResult Post(Bid newBid) { throw new NotImplementedException(); }
public void PlaceBid_WhenInvokedWithSameAmount_ArgumentExceptionIsThrown() { var auction = new Auction(_dummyItem, _dummyGuid, 1); var bid1 = new Bid(Guid.NewGuid(), 2); // First bid auction.PlaceBid(bid1); var bid2 = new Bid(Guid.NewGuid(), 2); // Second bid Assert.Throws<ArgumentException>(() => { auction.PlaceBid(bid2); }); }
public async Task <ActionResult> SendBid([FromBody] Bid bid) { await _bidRepository.SendBid(bid); return(Ok()); }
public async Task <ActionResult <Bid> > GetWinnerBid(string id) { Bid bid = await _bidRepository.GetWinnerBid(id); return(Ok(bid)); }
public void IfBidIsHigherThanPreviousBidsThenBidPlacedIsRaised() { var createAuctionCommand = Command.Create(_aggregateId, _createAuction); _subject.HandleCommand(createAuctionCommand); var placeBidCommand = Command.Create(_aggregateId, _placeBid); _subject.HandleCommand(placeBidCommand); var result = _subject.HandleCommand(Command.Create(_aggregateId, PlaceBid.Create(Bid.Create(11.5m)))); Assert.True(result is CommandResultSuccess); var newEvent = (result as CommandResultSuccess).Events.Single(); Assert.True(newEvent is BidPlaced); Assert.Equal(11.5m, (newEvent as BidPlaced).Bid.Amount); }
public BbtEntry LookupBlock(Bid bid) => _bbtReader.Find(bid);
override protected void Deactivate() { if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnection.Deactivate|ADV> %d# deactivating\n", base.ObjectID); } TdsParser bestEffortCleanupTarget = null; RuntimeHelpers.PrepareConstrainedRegions(); try { #if DEBUG TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection(); RuntimeHelpers.PrepareConstrainedRegions(); try { tdsReliabilitySection.Start(); #else { #endif //DEBUG bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(Connection); SqlReferenceCollection referenceCollection = (SqlReferenceCollection)ReferenceCollection; if (null != referenceCollection) { referenceCollection.Deactivate(); } // Invoke subclass-specific deactivation logic InternalDeactivate(); } #if DEBUG finally { tdsReliabilitySection.Stop(); } #endif //DEBUG } catch (System.OutOfMemoryException) { DoomThisConnection(); throw; } catch (System.StackOverflowException) { DoomThisConnection(); throw; } catch (System.Threading.ThreadAbortException) { DoomThisConnection(); SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget); throw; } catch (Exception e) { // if (!ADP.IsCatchableExceptionType(e)) { throw; } // if an exception occurred, the inner connection will be // marked as unusable and destroyed upon returning to the // pool DoomThisConnection(); ADP.TraceExceptionWithoutRethrow(e); } }
public bool CanApprove(Bid bid) { var user = (UserIdentity)System.Web.HttpContext.Current.User.Identity; return(bid.UserProfileId == user.Profile.UserProfileID); }
private void EnlistNonNull(SysTx.Transaction tx) { Debug.Assert(null != tx, "null transaction?"); if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnection.EnlistNonNull|ADV> %d#, transaction %d#.\n", base.ObjectID, tx.GetHashCode()); } bool hasDelegatedTransaction = false; if (IsYukonOrNewer) { if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnection.EnlistNonNull|ADV> %d#, attempting to delegate\n", base.ObjectID); } // Promotable transactions are only supported on Yukon // servers or newer. SqlDelegatedTransaction delegatedTransaction = new SqlDelegatedTransaction(this, tx); try { // NOTE: System.Transactions claims to resolve all // potential race conditions between multiple delegate // requests of the same transaction to different // connections in their code, such that only one // attempt to delegate will succeed. // NOTE: PromotableSinglePhaseEnlist will eventually // make a round trip to the server; doing this inside // a lock is not the best choice. We presume that you // aren't trying to enlist concurrently on two threads // and leave it at that -- We don't claim any thread // safety with regard to multiple concurrent requests // to enlist the same connection in different // transactions, which is good, because we don't have // it anyway. // PromotableSinglePhaseEnlist may not actually promote // the transaction when it is already delegated (this is // the way they resolve the race condition when two // threads attempt to delegate the same Lightweight // Transaction) In that case, we can safely ignore // our delegated transaction, and proceed to enlist // in the promoted one. if (tx.EnlistPromotableSinglePhase(delegatedTransaction)) { hasDelegatedTransaction = true; this.DelegatedTransaction = delegatedTransaction; if (Bid.AdvancedOn) { long transactionId = SqlInternalTransaction.NullTransactionId; int transactionObjectID = 0; if (null != CurrentTransaction) { transactionId = CurrentTransaction.TransactionId; transactionObjectID = CurrentTransaction.ObjectID; } Bid.Trace("<sc.SqlInternalConnection.EnlistNonNull|ADV> %d#, delegated to transaction %d# with transactionId=0x%I64x\n", base.ObjectID, transactionObjectID, transactionId); } } } catch (SqlException e) { // we do not want to eat the error if it is a fatal one if (e.Class >= TdsEnums.FATAL_ERROR_CLASS) { throw; } // if the parser is null or its state is not openloggedin, the connection is no longer good. SqlInternalConnectionTds tdsConnection = this as SqlInternalConnectionTds; if (tdsConnection != null) { TdsParser parser = tdsConnection.Parser; if (parser == null || parser.State != TdsParserState.OpenLoggedIn) { throw; } } ADP.TraceExceptionWithoutRethrow(e); // In this case, SqlDelegatedTransaction.Initialize // failed and we don't necessarily want to reject // things -- there may have been a legitimate reason // for the failure. } } if (!hasDelegatedTransaction) { if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnection.EnlistNonNull|ADV> %d#, delegation not possible, enlisting.\n", base.ObjectID); } byte[] cookie = null; if (null == _whereAbouts) { byte[] dtcAddress = GetDTCAddress(); if (null == dtcAddress) { throw SQL.CannotGetDTCAddress(); } _whereAbouts = dtcAddress; } cookie = GetTransactionCookie(tx, _whereAbouts); // send cookie to server to finish enlistment PropagateTransactionCookie(cookie); _isEnlistedInTransaction = true; if (Bid.AdvancedOn) { long transactionId = SqlInternalTransaction.NullTransactionId; int transactionObjectID = 0; if (null != CurrentTransaction) { transactionId = CurrentTransaction.TransactionId; transactionObjectID = CurrentTransaction.ObjectID; } Bid.Trace("<sc.SqlInternalConnection.EnlistNonNull|ADV> %d#, enlisted with transaction %d# with transactionId=0x%I64x\n", base.ObjectID, transactionObjectID, transactionId); } } EnlistedTransaction = tx; // Tell the base class about our enlistment // If we're on a Yukon or newer server, and we we delegate the // transaction successfully, we will have done a begin transaction, // which produces a transaction id that we should execute all requests // on. The TdsParser or SmiEventSink will store this information as // the current transaction. // // Likewise, propagating a transaction to a Yukon or newer server will // produce a transaction id that The TdsParser or SmiEventSink will // store as the current transaction. // // In either case, when we're working with a Yukon or newer server // we better have a current transaction by now. Debug.Assert(!IsYukonOrNewer || null != CurrentTransaction, "delegated/enlisted transaction with null current transaction?"); }
protected internal void DoNotPoolThisConnection() { this._cannotBePooled = true; Bid.PoolerTrace("<prov.DbConnectionInternal.DoNotPoolThisConnection|RES|INFO|CPOOL> %d#, Marking pooled object as non-poolable so it will be disposed\n", this.ObjectID); }
//Фильтры отображени/сокрытия строк таблиц private void SetViewSources() { equipmentBidViewSource.Source = EquipmentBidViewModel.instance().Collection; equipmentBidViewSource.Filter += delegate(object sender, FilterEventArgs e) { EquipmentBid equipmentBid = e.Item as EquipmentBid; if (equipmentBid == null) { return; } Bid bid = dgvBid.SelectedItem as Bid; if (bid == null) { e.Accepted = false; return; } if (bid.Id == equipmentBid.Id_bid) { e.Accepted = true; } else { e.Accepted = false; } }; complectationViewSource.Source = ComplectationViewModel.instance().Collection; complectationViewSource.Filter += delegate(object sender, FilterEventArgs e) { Complectation complectation = e.Item as Complectation; if (complectation == null) { return; } EquipmentBid equipmentBid = dgvEquipmentBid.SelectedItem as EquipmentBid; if (equipmentBid == null) { e.Accepted = false; return; } if (complectation.Id_equipment_bid == equipmentBid.Id) { e.Accepted = true; } else { e.Accepted = false; } }; buyerViewSource.Source = BuyerViewModel.instance().Collection; buyerViewSource.Filter += delegate(object sender, FilterEventArgs e) { Buyer buyer = e.Item as Buyer; if (buyer == null) { return; } Bid bid = dgvBid.SelectedItem as Bid; if (bid == null) { e.Accepted = false; return; } if (buyer.Id == bid.Id_buyer) { e.Accepted = true; } else { e.Accepted = false; } }; }
internal void SetInStasis() { this._isInStasis = true; Bid.PoolerTrace("<prov.DbConnectionInternal.SetInStasis|RES|CPOOL> %d#, Non-Pooled Connection has Delegated Transaction, waiting to Dispose.\n", this.ObjectID); this.PerformanceCounters.NumberOfStasisConnections.Increment(); }
internal ODBC32.RetCode GetConnectionAttribute(ODBC32.SQL_ATTR attribute, byte[] buffer, out int cbActual) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLGetConnectAttrW(this, attribute, buffer, buffer.Length, out cbActual); Bid.Trace("<odbc.SQLGetConnectAttr|ODBC> SQLRETURN=%d, Attribute=%d, BufferLength=%d, StringLength=%d\n", (int)retcode, (int)attribute, buffer.Length, (int)cbActual); return(retcode); }
public static Domain.Entities.Bid ToModel(this Bid vm) { return(Mapper.Map <Domain.Entities.Bid>(vm)); }
internal void method_6(Bid bid_0) { if (this.traceOnQuote && this.side == PositionSide.Long) { this.currPrice = this.GetPrice(bid_0.price); this.fillPrice = this.currPrice; this.trailPrice = this.currPrice; this.method_1(); } }
override protected int ExecuteBatch() { Debug.Assert(null != _commandSet && (0 < _commandSet.CommandCount), "no commands"); Bid.CorrelationTrace("<sc.SqlDataAdapter.ExecuteBatch|Info|Correlation> ObjectID%d#, ActivityID %ls\n", ObjectID); return(_commandSet.ExecuteNonQuery()); }
internal ODBC32.RetCode GetInfo1(ODBC32.SQL_INFO info, byte[] buffer) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLGetInfoW(this, info, buffer, checked ((short)buffer.Length), ADP.PtrZero); Bid.Trace("<odbc.SQLGetInfo|ODBC> SQLRETURN=%d, InfoType=%d, BufferLength=%d\n", (int)retcode, (int)info, buffer.Length); return(retcode); }
public void PlaceBid_WhenInvokedWithCorrectBid_BidIsSaved() { var auction = new Auction(_dummyItem, _dummyGuid, 1); var bid = new Bid(Guid.NewGuid(), 2); auction.PlaceBid(bid); // Assert var storedBid = auction.Bids.First(); Assert.AreEqual(bid.UserId, storedBid.UserId); Assert.AreEqual(bid.Amount, storedBid.Amount); Assert.AreEqual(bid.Time, storedBid.Time); }
internal ODBC32.RetCode SetConnectionAttribute3(ODBC32.SQL_ATTR attribute, string buffer, Int32 length) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLSetConnectAttrW(this, attribute, buffer, length); Bid.Trace("<odbc.SQLSetConnectAttr|ODBC> SQLRETURN=%d, Attribute=%d, BufferLength=%d\n", (int)retcode, (int)attribute, buffer.Length); return(retcode); }
public void CustomerWin(Bid bidder) { var context = new SidejobEntities(); var customerwinbid = new CustomerWinBid { BidID = bidder.BidID, CustomerID = bidder.BidderID, NumberofBids = GetCustomerNumberofBids(bidder.BidderID) }; context.AddToCustomerWinBids(customerwinbid); context.DeleteObject(bidder); context.SaveChanges(); }
public void SaveBid(Bid bid) { context.Bids.Add(bid); context.SaveChanges(); }
public IHttpActionResult PostBid([FromUri] int id, [FromBody]BidBindingModel model) { var currentUserId = User.Identity.GetUserId(); var currentUser = this.db.Users.Find(currentUserId); if (!ModelState.IsValid) { return BadRequest(ModelState); } if (model == null) { return BadRequest(); } var offer = this.db.Offers.Find(id); if (offer == null) { return NotFound(); } if (DateTime.Now > offer.ExpirationDate) { return BadRequest("Offer has expired."); } var offerCurrentPrice = offer.Bids.OrderByDescending(b => b.Price).Select(b => b.Price).FirstOrDefault() > offer.InitialPrice ? offer.Bids.OrderByDescending(b => b.Price).Select(b => b.Price).FirstOrDefault() : offer.InitialPrice; if (model.BidPrice <= offerCurrentPrice) { return BadRequest("Your bid should be > " + offerCurrentPrice); } var newBid = new Bid() { Price = model.BidPrice, Bidder = currentUser, Comment = model.Comment, Date = DateTime.Now, Offer = offer }; offer.Bids.Add(newBid); db.SaveChanges(); return this.Ok( new { Id = newBid.Id, Bidder = currentUser.UserName, Message = "Bid created." }); }
private void LoginNoFailover(ServerInfo serverInfo, string newPassword, bool redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) { int num2 = 0; ServerInfo info = serverInfo; if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnectionTds.LoginNoFailover|ADV> %d#, host=%ls\n", base.ObjectID, serverInfo.UserServerName); } int num = 100; this.ResolveExtendedServerName(serverInfo, !redirectedUserInstance, owningObject); Label_0032: if (this._parser != null) { this._parser.Disconnect(); } this._parser = new TdsParser(base.ConnectionOptions.MARS, base.ConnectionOptions.Asynchronous); try { this.AttemptOneLogin(serverInfo, newPassword, true, timeout, owningObject); if (connectionOptions.MultiSubnetFailover && (this.ServerProvidedFailOverPartner != null)) { bool serverProvidedFailoverPartner = true; throw SQL.MultiSubnetFailoverWithFailoverPartner(serverProvidedFailoverPartner); } if (this._routingInfo == null) { if (this.PoolGroupProviderInfo != null) { this.PoolGroupProviderInfo.FailoverCheck(this, false, connectionOptions, this.ServerProvidedFailOverPartner); } base.CurrentDataSource = info.UserServerName; return; } Bid.Trace("<sc.SqlInternalConnectionTds.LoginNoFailover> Routed to %ls", serverInfo.ExtendedServerName); if (num2 > 0) { throw SQL.ROR_RecursiveRoutingNotSupported(); } if (timeout.IsExpired) { throw SQL.ROR_TimeoutAfterRoutingInfo(); } serverInfo = new ServerInfo(base.ConnectionOptions, this._routingInfo, serverInfo.ResolvedServerName); this._currentPacketSize = base.ConnectionOptions.PacketSize; this._currentLanguage = this._originalLanguage = base.ConnectionOptions.CurrentLanguage; base.CurrentDatabase = this._originalDatabase = base.ConnectionOptions.InitialCatalog; this._currentFailoverPartner = null; this._instanceName = string.Empty; num2++; goto Label_0032; } catch (SqlException exception) { if (((this._parser == null) || (this._parser.State != TdsParserState.Closed)) || (this.IsDoNotRetryConnectError(exception) || timeout.IsExpired)) { throw; } if (timeout.MillisecondsRemaining <= num) { throw; } } if (this.ServerProvidedFailOverPartner != null) { if (connectionOptions.MultiSubnetFailover) { bool flag = true; throw SQL.MultiSubnetFailoverWithFailoverPartner(flag); } this.LoginWithFailover(true, serverInfo, this.ServerProvidedFailOverPartner, newPassword, redirectedUserInstance, owningObject, connectionOptions, timeout); } else { if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnectionTds.LoginNoFailover|ADV> %d#, sleeping %d{milisec}\n", base.ObjectID, num); } Thread.Sleep(num); num = (num < 500) ? (num * 2) : 0x3e8; goto Label_0032; } }
public Bid PlaceBid(Bid newbid) { try { var b = new bid { itemno = newbid.itemno, userID = newbid.userID, value = newbid.value, username = newbid.username }; _db.bid.Add(b); _db.SaveChanges(); newbid.bidID = b.bidID; return newbid; } catch (Exception e) { Console.Error.WriteLine("Place bid threw: \n" + e.Message); return null; } }
private void LoginWithFailover(bool useFailoverHost, ServerInfo primaryServerInfo, string failoverHost, string newPassword, bool redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) { long num5; if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnectionTds.LoginWithFailover|ADV> %d#, useFailover=%d{bool}, primary=", base.ObjectID, useFailoverHost); Bid.PutStr(primaryServerInfo.UserServerName); Bid.PutStr(", failover="); Bid.PutStr(failoverHost); Bid.PutStr("\n"); } int num = 100; string networkLibrary = base.ConnectionOptions.NetworkLibrary; ServerInfo serverInfo = new ServerInfo(connectionOptions, failoverHost); this.ResolveExtendedServerName(primaryServerInfo, !redirectedUserInstance, owningObject); if (this.ServerProvidedFailOverPartner == null) { this.ResolveExtendedServerName(serverInfo, !redirectedUserInstance && (failoverHost != primaryServerInfo.UserServerName), owningObject); } if (timeout.IsInfinite) { ADP.TimerFromSeconds(15); num5 = 0L; } else { num5 = (long)(0.08f * timeout.MillisecondsRemaining); } bool flag = false; int num2 = 0; while (true) { ServerInfo info2; long milliseconds = num5 * ((num2 / 2) + 1); long millisecondsRemaining = timeout.MillisecondsRemaining; if (milliseconds > millisecondsRemaining) { milliseconds = millisecondsRemaining; } TimeoutTimer timer = TimeoutTimer.StartMillisecondsTimeout(milliseconds); if (this._parser != null) { this._parser.Disconnect(); } this._parser = new TdsParser(base.ConnectionOptions.MARS, base.ConnectionOptions.Asynchronous); if (useFailoverHost) { if (!flag) { this.FailoverPermissionDemand(); flag = true; } if ((this.ServerProvidedFailOverPartner != null) && (serverInfo.ResolvedServerName != this.ServerProvidedFailOverPartner)) { if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnectionTds.LoginWithFailover|ADV> %d#, new failover partner=%ls\n", base.ObjectID, this.ServerProvidedFailOverPartner); } serverInfo.SetDerivedNames(networkLibrary, this.ServerProvidedFailOverPartner); } info2 = serverInfo; } else { info2 = primaryServerInfo; } try { this.AttemptOneLogin(info2, newPassword, false, timer, owningObject); if (this._routingInfo != null) { Bid.Trace("<sc.SqlInternalConnectionTds.LoginWithFailover> Routed to %ls", this._routingInfo.ServerName); throw SQL.ROR_UnexpectedRoutingInfo(); } break; } catch (SqlException exception) { if (this.IsDoNotRetryConnectError(exception) || timeout.IsExpired) { throw; } if (base.IsConnectionDoomed) { throw; } if ((1 == (num2 % 2)) && (timeout.MillisecondsRemaining <= num)) { throw; } } if (1 == (num2 % 2)) { if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnectionTds.LoginWithFailover|ADV> %d#, sleeping %d{milisec}\n", base.ObjectID, num); } Thread.Sleep(num); num = (num < 500) ? (num * 2) : 0x3e8; } num2++; useFailoverHost = !useFailoverHost; } if (useFailoverHost && (this.ServerProvidedFailOverPartner == null)) { throw SQL.InvalidPartnerConfiguration(failoverHost, base.CurrentDatabase); } if (this.PoolGroupProviderInfo != null) { this.PoolGroupProviderInfo.FailoverCheck(this, useFailoverHost, connectionOptions, this.ServerProvidedFailOverPartner); } base.CurrentDataSource = useFailoverHost ? failoverHost : primaryServerInfo.UserServerName; }
public void Add(Bid bid) { _session.Save(bid); }
internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) { OleDbHResult description; UnsafeNativeMethods.ISQLErrorInfo info2; int lCID = CultureInfo.CurrentCulture.LCID; Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS>\n"); UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lCID); if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS>\n"); description = errorInfo.GetDescription(out this.message); Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> Message='%ls'\n", this.message); if (OleDbHResult.DB_E_NOLOCALE == description) { Bid.Trace("<oledb.ReleaseComObject|API|OS> ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); Bid.Trace("<oledb.Kernel32.GetUserDefaultLCID|API|OS>\n"); lCID = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS> LCID=%d\n", lCID); errorInfo = errorRecords.GetErrorInfo(index, lCID); if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS>\n"); description = errorInfo.GetDescription(out this.message); Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> Message='%ls'\n", this.message); } } if ((description < OleDbHResult.S_OK) && ADP.IsEmpty(this.message)) { this.message = ODB.FailedGetDescription(description); } if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS>\n"); description = errorInfo.GetSource(out this.source); Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> Source='%ls'\n", this.source); if (OleDbHResult.DB_E_NOLOCALE == description) { Marshal.ReleaseComObject(errorInfo); Bid.Trace("<oledb.Kernel32.GetUserDefaultLCID|API|OS>\n"); lCID = SafeNativeMethods.GetUserDefaultLCID(); Bid.Trace("<oledb.IErrorRecords.GetErrorInfo|API|OS> LCID=%d\n", lCID); errorInfo = errorRecords.GetErrorInfo(index, lCID); if (errorInfo != null) { Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS>\n"); description = errorInfo.GetSource(out this.source); Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> Source='%ls'\n", this.source); } } if ((description < OleDbHResult.S_OK) && ADP.IsEmpty(this.source)) { this.source = ODB.FailedGetSource(description); } Bid.Trace("<oledb.Marshal.ReleaseComObject|API|OS> ErrorInfo\n"); Marshal.ReleaseComObject(errorInfo); } } Bid.Trace("<oledb.IErrorRecords.GetCustomErrorObject|API|OS> IID_ISQLErrorInfo\n"); description = errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out info2); if (info2 != null) { Bid.Trace("<oledb.ISQLErrorInfo.GetSQLInfo|API|OS>\n"); this.nativeError = info2.GetSQLInfo(out this.sqlState); Bid.Trace("<oledb.ReleaseComObject|API|OS> SQLErrorInfo\n"); Marshal.ReleaseComObject(info2); } }
internal ODBC32.RetCode GetInfo2(ODBC32.SQL_INFO info, byte[] buffer, out short cbActual) { ODBC32.RetCode retcode = UnsafeNativeMethods.SQLGetInfoW(this, info, buffer, checked ((short)buffer.Length), out cbActual); Bid.Trace("<odbc.SQLGetInfo|ODBC> SQLRETURN=%d, InfoType=%d, BufferLength=%d, StringLength=%d\n", (int)retcode, (int)info, buffer.Length, (int)cbActual); return(retcode); }
void ReceiveBid(Bid bid) { if (bid.Amount > HighBid) HighBid = bid.Amount; }