public ContentContainerViewModel(BidViewModel bidViewModel, BidHistory bidHistory) { BidViewModel = bidViewModel; RecentActivity = new RecentBidActivityViewModel(bidHistory); AddTabItem(BidViewModel); AddTabItem(RecentActivity); }
public void Serialize(GenericWriter writer) { writer.Write(1); writer.Write(Owner); writer.Write(AuctionItem); writer.Write(CurrentBid); writer.Write(StartBid); writer.Write(Buyout); writer.Write(Description); writer.Write(Duration); writer.Write(StartTime); writer.Write(OnGoing); writer.Write(Bids.Count); Bids.ForEach(b => { writer.Write(b.Mobile); b.Serialize(writer); }); writer.Write(BidHistory != null ? BidHistory.Count : 0); if (BidHistory != null) { BidHistory.ForEach(e => e.Serialize(writer)); } }
public async Task <IActionResult> Edit(int id, [Bind("BidHistoryId,BidDate,BidAmount,ItemId")] BidHistory bidHistory) { if (id != bidHistory.BidHistoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bidHistory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BidHistoryExists(bidHistory.BidHistoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(bidHistory)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,ListingId,Date,Amount")] BidHistory bidHistory) { if (id != bidHistory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { AuctionContext.Update(bidHistory); await AuctionContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BidHistoryExists(bidHistory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["ListingId"] = new SelectList(AuctionContext.Listings, "Id", "Id", bidHistory.ListingId); ViewData["UserId"] = new SelectList(AuctionContext.Users, "UserId", "Email", bidHistory.UserId); return(View(bidHistory)); }
public void AddBid_fails_if_cannot_insert_bid_with_existing_amount() { Buyer buyer; BidSession session; CreateBidSession(out buyer, out session); var history = new BidHistory() { Buyer = buyer, Session = session, Bid = 10 }; var repo = ObjectFactory.Get<IRepository<BidHistory, Guid>>(); repo.Insert(history); var buyer2 = new Buyer() { Name = "Ertan2", Surname = "Ergun2" }; var repoBuyer = ObjectFactory.Get<IRepository<Buyer, Guid>>(); repoBuyer.Insert(buyer2); var sut = ObjectFactory.Get<IBidManager>(); Assert.Throws<ManagerException>(() => { sut.AddBid(buyer2, session, 10); }); }
public ActionResult DeleteConfirmed(int id) { BidHistory bidHistory = db.BidHistories.Find(id); db.BidHistories.Remove(bidHistory); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Handle(CreateBidHistoryCommand command) { var auctionId = new AuctionId(command.AuctionId); var money = new Money(command.OfferedAmount, "USD"); var bidHistory = new BidHistory(auctionId, command.BidderId, money, command.CreateDateTime); _repository.Add(bidHistory); }
public BidViewModel(ObservableCollection <Bid> bids, BidData bidData, BidHistory bidHistory) { HeaderText = "Bid Items"; Bids = bids; BidData = bidData; BidHistory = bidHistory; SetBidAggregateViewModel(); }
private void AddToHistory(Mobile m, long highBid) { if (BidHistory == null) { BidHistory = new List <HistoryEntry>(); } BidHistory.Add(new HistoryEntry(m, highBid)); }
public bool AcceptBid(Bid bid) { var accepted = false; if (Expires < DateTime.Now) { BidHistory.Add(bid); CurrentBid = bid; accepted = true; } return(accepted); }
public Auction(AuctionSafe safe, GenericReader reader) { Safe = safe; int version = reader.ReadInt(); Owner = reader.ReadMobile(); AuctionItem = reader.ReadItem(); CurrentBid = reader.ReadLong(); StartBid = reader.ReadLong(); Buyout = reader.ReadLong(); Description = reader.ReadString(); Duration = reader.ReadInt(); StartTime = reader.ReadDateTime(); OnGoing = reader.ReadBool(); Bids = new List <BidEntry>(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PlayerMobile m = reader.ReadMobile() as PlayerMobile; BidEntry entry = new BidEntry(m, reader); if (m != null) { Bids.Add(entry); if (entry.CurrentBid > 0 && (HighestBid == null || entry.CurrentBid > HighestBid.CurrentBid)) { HighestBid = entry; } } } count = reader.ReadInt(); if (count > 0) { BidHistory = new List <HistoryEntry>(); } for (int i = 0; i < count; i++) { BidHistory.Add(new HistoryEntry(reader)); } if (HasBegun) { Auctions.Add(this); } }
public RecentBidActivityViewModel(BidHistory bidHistory) { HeaderText = "Recent Activity"; Hours = 1; BidActivityHistoryViewModel = new BidActivityHistoryViewModel(); BidHistoryItems = new ObservableCollection <BidHistoryItem>(); BidHistory = bidHistory; SearchActivityCommand = new ActionCommand(SearchActivity); SearchActivity(); }
public async Task <IActionResult> Create([Bind("Id,UserId,ListingId,Date,Amount")] BidHistory bidHistory) { if (ModelState.IsValid) { AuctionContext.Add(bidHistory); await AuctionContext.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["ListingId"] = new SelectList(AuctionContext.Listings, "Id", "Id", bidHistory.ListingId); ViewData["UserId"] = new SelectList(AuctionContext.Users, "UserId", "Email", bidHistory.UserId); return(View(bidHistory)); }
private async void OpenBidHistory(object obj) { var view = new BidHistory { DataContext = new BidHistoryViewModel { Bids = new ObservableCollection <Bid>(_bids.OrderByDescending(b => b.Amount)), Title = _title } }; await DialogHost.Show(view, "RootDialog"); }
// GET: BidHistories/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BidHistory bidHistory = db.BidHistories.Find(id); if (bidHistory == null) { return(HttpNotFound()); } return(View(bidHistory)); }
public void AddBidHistoryToFile(BidHistory bidHistory) { XDocument bidHistoryDocument = XDocument.Load(_bidHistoryPath); XElement root = bidHistoryDocument.Root; var items = root.Element("BidHistoryItems"); foreach (var history in bidHistory.BidHistoryItems) { XElement element = history.ToXElement <BidHistoryItem>(); items.Add(element); } bidHistoryDocument.Save(_bidHistoryPath); }
public ActionResult Edit([Bind(Include = "ID,LinkID,RollId,Lot,SellerId,BuyerId,BiddingPrice,BidTotalPrice,DateTimeBid,UserID")] BidHistory bidHistory) { if (ModelState.IsValid) { db.Entry(bidHistory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LinkID = new SelectList(db.tblRolls, "ID", "Lot", bidHistory.LinkID); ViewBag.SellerId = new SelectList(db.tblCustomers, "ID", "CustomerID", bidHistory.SellerId); ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CustomerID", bidHistory.BuyerId); ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", bidHistory.RollId); ViewBag.UserID = new SelectList(db.tblCustomers, "ID", "CustomerID", bidHistory.UserID); return(View(bidHistory)); }
public bool CheckForBidChanges(List <Bid> currentBids, List <Bid> newBids) { BidHistory newBidHistory = new BidHistory(); foreach (var nBid in newBids) { bool changed = false; var cBid = currentBids.FirstOrDefault(x => x.LotNumber == nBid.LotNumber); if (cBid == null) { changed = true; } else if (nBid != null) { if (cBid.BidCount < nBid.BidCount) //bidCountChange { changed = true; } else if (cBid.CurrentBid != nBid.CurrentBid) { changed = true; } } if (changed) { BidHistoryItem bidHistory = new BidHistoryItem(); bidHistory.DateTime = DateTime.Now; bidHistory.Bid = nBid; newBidHistory.BidHistoryItems.Add(bidHistory); } } if (currentBids.Count < newBids.Count) { var onlyNew = newBids.Where(x => currentBids.FirstOrDefault(y => y.LotNumber == x.LotNumber) == null).ToList(); AddBidDataToFile(onlyNew); } if (newBidHistory.BidHistoryItems.Count > 0) { AddBidHistoryToFile(newBidHistory); return(true); } return(false); }
public void Delete_Fails_If_throws_exception_or_returns_not_null() { var buyer = new Buyer() { Name = "Ertan", Surname = "Ergun" }; var repoBuyer = ObjectFactory.Get<IRepository<Buyer, Guid>>(); repoBuyer.Insert(buyer); var artifact = new Artifact() { Name = "Test", Description = "Desc", ImagePath = "none" }; var repoArtifact = ObjectFactory.Get<IRepository<Artifact, Guid>>(); repoArtifact.Insert(artifact); var session = new BidSession() { Artifact = artifact, Date = DateTime.Now }; var repoSession = ObjectFactory.Get<IRepository<BidSession, Guid>>(); repoSession.Insert(session); var history = new BidHistory() { Buyer = buyer, Session = session, Bid = 1 }; var sut = ObjectFactory.Get<IRepository<BidHistory, Guid>>(); sut.Insert(history); var result = sut.GetById(history.Id); Assert.NotNull(result); Assert.AreEqual(history.Id, result.Id); sut.Delete(history); result = sut.GetById(history.Id); Assert.Null(result); }
// GET: BidHistories/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BidHistory bidHistory = db.BidHistories.Find(id); if (bidHistory == null) { return(HttpNotFound()); } ViewBag.LinkID = new SelectList(db.tblRolls, "ID", "Lot", bidHistory.LinkID); ViewBag.SellerId = new SelectList(db.tblCustomers, "ID", "CustomerID", bidHistory.SellerId); ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CustomerID", bidHistory.BuyerId); ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description", bidHistory.RollId); ViewBag.UserID = new SelectList(db.tblCustomers, "ID", "CustomerID", bidHistory.UserID); return(View(bidHistory)); }
public ObservableCollection <Bid> GetCurrentBidsFromHistory() { ObservableCollection <Bid> currentBids = new ObservableCollection <Bid>(); //load bidhistory and data XmlSerializer serializer = new XmlSerializer(typeof(BidHistory)); using (var reader = XmlReader.Create(_bidHistoryPath)) { _bidhistory = (BidHistory)serializer.Deserialize(reader); } serializer = new XmlSerializer(typeof(BidData)); using (var reader = XmlReader.Create(_bidDataPath)) { _bidData = (BidData)serializer.Deserialize(reader); } foreach (var bidDataItem in _bidData.BidDataItems) { BidHistoryItem latest = null; foreach (var item in _bidhistory.BidHistoryItems) { if (item.Bid.LotNumber == bidDataItem.Bid.LotNumber) { if (latest == null) { latest = item; } else if (item.DateTime > latest.DateTime) { latest = item; } } } currentBids.Add(latest.Bid); } return(currentBids); }
protected override void OnStopRunning() { EntityManager.CompleteAllJobs(); _tradeAsks.Dispose(); _tradeBids.Dispose(); _deltaMoney.Dispose(); _profitsByLogic.Dispose(); _bankrupt.Dispose(); AskHistory.Dispose(); BidHistory.Dispose(); TradeHistory.Dispose(); PriceHistory.Dispose(); ProfitsHistory.Dispose(); RatioHistory.Dispose(); FieldHistory.Dispose(); _logicEntities.Dispose(); _goodsMostLogic.Dispose(); }
public async Task <Event> Bid(BidHistory obj) { var bidderId = (await _bllUsers.GetByUsernameAsync(obj.Username)).Id; var objEvent = await GetEventDetails(obj.EventId); //if bidAmount has changed before refreshing on the user's screen and is smaller than other biders' bid then return null if (obj.BidAmount <= objEvent.CurrentPrice) { objEvent.PriceChanged = true; return(objEvent); } //update event's currentPrice property and set TopBidder var successEvent = await _bllEvents.UpdateAsync(new BO.Event() { CurrentPrice = obj.BidAmount, TopBidder = bidderId, Id = objEvent.Id, ItemId = objEvent.ItemId, AuctionId = objEvent.AuctionId, StartDate = objEvent.StartDate, EndDate = objEvent.EndDate, Lun = objEvent.Lun, Lud = objEvent.Lud, MinPriceIncrementAmount = objEvent.MinPriceIncrementAmount }); //register bidHistory var successBid = await _bllBidHistories.AddAsync(new BO.BidHistory() { AuctionId = obj.AuctionId, EventId = obj.EventId, UserId = bidderId, BidAmount = obj.BidAmount, BidDate = DateTime.Now }); var x = Mapper.Event(await _bllEvents.GetAsync(obj.EventId)); return(x); }
public void Initialize() { if (!File.Exists(_bidDataPath)) { var bidData = new BidData(); var serializer = new XmlSerializer(typeof(BidData)); using (var writer = XmlWriter.Create(_bidDataPath)) { serializer.Serialize(writer, bidData); } } if (!File.Exists(_bidHistoryPath)) { var bidHistory = new BidHistory(); var serializer = new XmlSerializer(typeof(BidHistory)); using (var writer = XmlWriter.Create(_bidHistoryPath)) { serializer.Serialize(writer, bidHistory); } } }
public IActionResult Post([FromBody] BidHistory history) { string userWithTheHighestBid = _context.BidHistories.Where(b => b.AntiqueId == history.AntiqueId).OrderByDescending(b => b.BidAmount).Select(b => b.User).Take(1).SingleOrDefault(); string loggedInUser = CustomAuthentication.AppContext.Current.Session.GetString("user"); if ((string.IsNullOrEmpty(userWithTheHighestBid) || userWithTheHighestBid != loggedInUser) && !string.IsNullOrEmpty(loggedInUser)) { Antique antique = _context.Antiques.Where(a => a.Id == history.AntiqueId).SingleOrDefault(); DateTime localDate = DateTime.Now; if (antique.BidEndTime < localDate) { return(StatusCode(2)); } if (antique.CurrentBid < history.BidAmount) { BidHistory bidHistory = new BidHistory(); bidHistory.AntiqueId = history.AntiqueId; bidHistory.BidAmount = history.BidAmount; bidHistory.BidTime = localDate; bidHistory.User = loggedInUser; antique.CurrentBid = history.BidAmount; _context.Update(antique); _context.Add(bidHistory); _context.SaveChanges(); } else { return(StatusCode(3)); } } else { return(StatusCode(1)); } return(Ok(history.BidAmount)); }
public void SetBidHistory(BidHistory bidHistory) { BidHistory = bidHistory; SearchActivity(); }
public void Update_Fails_If_throws_exception() { var buyer = new Buyer() { Name = "Ertan", Surname = "Ergun" }; var repoBuyer = ObjectFactory.Get<IRepository<Buyer, Guid>>(); repoBuyer.Insert(buyer); var artifact = new Artifact() { Name = "Test", Description = "Desc", ImagePath = "none" }; var repoArtifact = ObjectFactory.Get<IRepository<Artifact, Guid>>(); repoArtifact.Insert(artifact); var session = new BidSession() { Artifact = artifact, Date = DateTime.Now }; var repoSession = ObjectFactory.Get<IRepository<BidSession, Guid>>(); repoSession.Insert(session); var history = new BidHistory() { Buyer = buyer, Session = session, Bid = 1 }; var sut = ObjectFactory.Get<IRepository<BidHistory, Guid>>(); sut.Insert(history); history.Bid = 2; sut.Update(history); }
public BidHistoryViewModel(BidHistory bidHistory) { BidHistory = bidHistory; }
public void Add(BidHistory history) { }
public BidResult submitBidResultByBidder(bool value, int bidId, int userId) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlDataReader reader; int success = -1; List <BidHistory> history = null; BidResult bidResult = new BidResult(); try { connection.Open(); SqlCommand command = new SqlCommand("USP_UpdateBidResultByBidder", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Value", value)); command.Parameters.Add(new SqlParameter("@BidId", bidId)); command.Parameters.Add(new SqlParameter("@UserId", userId)); reader = command.ExecuteReader(); while (reader.Read()) { bidResult.IsSucceed = Convert.ToInt32(reader["IsSucceed"]); bidResult.InFavour = Convert.ToInt32(reader["InFavour"]); bidResult.Against = Convert.ToInt32(reader["Against"]); if (bidResult.IsSucceed == 1) { history = new List <BidHistory>(); if (reader.NextResult()) { while (reader.Read()) { BidHistory bidHistory = new BidHistory(); string teamA = reader["TeamA"].ToString(); string teamB = reader["TeamB"].ToString(); bidHistory.Match = teamA + " VS " + teamB; if (reader["Team"].ToString() == "A") { bidHistory.Question = teamA + " : " + reader["Question"].ToString(); } else { bidHistory.Question = teamB + " : " + reader["Question"].ToString(); } bidHistory.Points = reader["BidPoints"].ToString(); bool answer = Convert.ToBoolean(reader["UserBid"].ToString()); if (answer) { bidHistory.Answer = "Yes"; } else { bidHistory.Answer = "No"; } history.Add(bidHistory); } } } } bidResult.BidHistory = history; } catch (Exception ex) { } return(bidResult); } }
/// <summary> /// Creates initial content for the database /// </summary> protected void CreateDummyData() { var buyer = new Buyer() { Name = "Dummy", Surname = "User" }; var repoBuyer = ObjectFactory.Get<IRepository<Buyer, Guid>>(); repoBuyer.Insert(buyer); var artifact = new Artifact() { Name = "A. Lange & Söhne Lange", Description = "Modern & Vintage Timepieces", ImagePath = "/Content/img/watch.jpg" }; var repoArtifact = ObjectFactory.Get<IRepository<Artifact, Guid>>(); repoArtifact.Insert(artifact); var session = new BidSession() { Artifact = artifact, Date = DateTime.Now }; var repoSession = ObjectFactory.Get<IRepository<BidSession, Guid>>(); repoSession.Insert(session); var history = new BidHistory() { Buyer = buyer, Session = session, Bid = 10 }; var sut = ObjectFactory.Get<IRepository<BidHistory, Guid>>(); sut.Insert(history); }
public List <BidHistory> getBidderHistory(int userId, out bool isBidActive, int masterId = 0) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlDataReader reader; List <BidHistory> history = new List <BidHistory>(); isBidActive = false; try { connection.Open(); SqlCommand command = new SqlCommand("USP_GETUSERBIDHISTORY", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@UserId", userId)); command.Parameters.Add(new SqlParameter("@MasterId", masterId)); command.Parameters.Add("@IsBidActive ", SqlDbType.Bit).Direction = ParameterDirection.Output; reader = command.ExecuteReader(); decimal pointswin = 0; decimal pointsloose = 0; decimal pointsdraw = 0; while (reader.Read()) { BidHistory bhistory = new BidHistory(); string teamA = reader["TeamA"].ToString(); string teamB = reader["TeamB"].ToString(); bhistory.Match = teamA + " VS " + teamB; if (reader["Team"].ToString() == "A") { bhistory.Question = teamA + " : " + reader["Question"].ToString(); } else { bhistory.Question = teamB + " : " + reader["Question"].ToString(); } bhistory.MatchDate = reader["MatchDate"].ToString(); pointsloose = Convert.ToDecimal(reader["PointsLoose"]); pointswin = Convert.ToDecimal(reader["PointsWin"]); if (reader["PointDraw"] != DBNull.Value) { pointsdraw = Convert.ToDecimal(reader["PointDraw"]); } if (pointsloose != 0) { bhistory.Points = pointsloose.ToString("0.00"); } else if (pointswin != 0) { bhistory.Points = "+" + pointswin.ToString("0.00"); } else if (pointsdraw != 0) { bhistory.Points = pointsdraw.ToString("0.00"); } bool userBid = Convert.ToBoolean(reader["UserBid"]); if (userBid) { bhistory.Answer = "Yes"; } else { bhistory.Answer = "No"; } history.Add(bhistory); } isBidActive = Convert.ToBoolean(command.Parameters["@IsBidActive"].Value); } catch (Exception ex) { } return(history); } }
public BidDetailViewModel(BidHistory bidHistory) { BidHistoryViewModel = new BidHistoryViewModel(bidHistory); }
public async Task <IActionResult> Create([Bind("BidDate,BidAmount,ItemId,AuctionId,ItemCurrentBid,ItemMinimumBid,Bidder_FirstName,Bidder_LastName,Bidder_PhoneNumber,Bidder_EmailAddress")] BidCreateViewModel bid) { //Retrieve this stuff just incase of validation errors: var media = _context.Media.Where(x => x.ItemId == bid.ItemId).ToList(); var item = _context.Items.Where(x => x.ItemId == bid.ItemId).SingleOrDefault(); bool HasErrors = false; double ItemMinimumBid = GetMinimumBidByItemId(bid.ItemId); if (bid.BidAmount < ItemMinimumBid) { ModelState.AddModelError("BidAmount", "Your bid must be greater than or equal to the minimum bid."); //return RedirectToAction("Create", new { ItemId = bid.ItemId, AuctionId = bid.AuctionId }); //Re-retrieve some values to prevent null exceptions bid.Media = media; bid.Item = item; HasErrors = true; } //Manual validations... Please don't look too close at the laziness. if (String.IsNullOrWhiteSpace(bid.Bidder_FirstName)) { ModelState.AddModelError("Bidder_FirstName", "Please enter your first name."); HasErrors = true; } if (string.IsNullOrWhiteSpace(bid.Bidder_LastName)) { ModelState.AddModelError("Bidder_LastName", "Please enter your last name."); HasErrors = true; } if (String.IsNullOrWhiteSpace(bid.Bidder_PhoneNumber)) { ModelState.AddModelError("Bidder_PhoneNumber", "Please a valid phone number."); HasErrors = true; } if (String.IsNullOrWhiteSpace(bid.Bidder_EmailAddress)) { ModelState.AddModelError("Bidder_EmailAddress", "Please a valid email address."); HasErrors = true; } if (HasErrors) { return(View(bid)); } Bidder newBidder = new Bidder { FirstName = bid.Bidder_FirstName, LastName = bid.Bidder_LastName, PhoneNumber = bid.Bidder_PhoneNumber, EmailAddress = bid.Bidder_EmailAddress, IsRegistered = false, Password = "******", Security = "derpaderp" }; _context.Bidders.Add(newBidder); await _context.SaveChangesAsync(); BidHistory newBid = new BidHistory { //Auction = _context.Auctions.SingleOrDefault(a => a.AuctionId == 1), //Temp debug workaround because AuctionId keeps passing in as 0. //Auction = _context.Auctions.SingleOrDefault(a => a.AuctionID == bid.AuctionId), BidDate = bid.BidDate, BidAmount = bid.BidAmount, ItemId = bid.ItemId, BidderId = newBidder.BidderID //Bidder = _context.Bidders.FirstOrDefault(b => b.FirstName == bid.Bidder_FirstName && b.LastName == bid.Bidder_LastName) }; var AddedBid = _context.BidHistory.Add(newBid); int SavedValue = await _context.SaveChangesAsync(); return(RedirectToAction("Index", "BidHistories", new { id = bid.AuctionId })); }