public ParticipantAction AddAction(Transaction transaction) { ParticipantAction action = new ParticipantAction(); action.Action = "Paid $" + transaction.Money + " for " + transaction.Description + "."; action.Time = DateTime.Now; action.ParticipantId = transaction.ParticipantId; context.ParticipantActions.Add(action); return(action); }
public ParticipantAction AddAction(RafflePrize rafflePrize, int tickets) { ParticipantAction action = new ParticipantAction(); var currentUser = User.Identity.GetUserId(); Participant participant = context.Participants.FirstOrDefault(p => p.ApplicationUserId == currentUser); action.Action = "Placed " + tickets + " tickets for " + rafflePrize.Name + "."; action.Time = DateTime.Now; action.ParticipantId = participant.ParticipantId; context.ParticipantActions.Add(action); context.SaveChanges(); return(action); }
public ParticipantAction AddAction(Raffle raffle, int tickets) { ParticipantAction action = new ParticipantAction(); var currentUser = User.Identity.GetUserId(); Participant participant = context.Participants.FirstOrDefault(p => p.ApplicationUserId == currentUser); action.Action = "Acquired " + tickets + " for " + raffle.Name + ", please pay for your tickets in the transactions tab."; action.Time = DateTime.Now; action.ParticipantId = participant.ParticipantId; context.ParticipantActions.Add(action); context.SaveChanges(); return(action); }
public ActionResult Bid([Bind(Include = "AuctionPrizeId,ActualValue,MinimumBid,BidIncrement,CurrentBid,Description,TopParticipant,Category,WinnerId,AuctionId,Participant,Paid,CustomBid")] AuctionPrize auctionPrize, int id) { try { var currentUserId = User.Identity.GetUserId(); var auctionPrizeToEdit = context.AuctionPrizes.FirstOrDefault(a => a.AuctionPrizeId == id); Participant participant = context.Participants.FirstOrDefault(p => p.ApplicationUserId == currentUserId); Auction auction = context.Auctions.FirstOrDefault(u => u.AuctionId == auctionPrizeToEdit.AuctionId); Participant outbidParticipant = context.Participants.FirstOrDefault(o => o.ParticipantId == auctionPrizeToEdit.TopParticipant); if (auctionPrize.CustomBid == 0) { if (auctionPrizeToEdit.CurrentBid == 0) { auctionPrizeToEdit.CurrentBid += auctionPrizeToEdit.MinimumBid; auction.TotalRaised += auctionPrizeToEdit.MinimumBid; } else { auctionPrizeToEdit.CurrentBid += auctionPrizeToEdit.BidIncrement; auction.TotalRaised += auctionPrizeToEdit.BidIncrement; ParticipantAction participantActionOutBid = new ParticipantAction(); participantActionOutBid.ParticipantId = auctionPrizeToEdit.TopParticipant; participantActionOutBid.Action = "You have been outbid on " + auctionPrizeToEdit.Name + "."; participantActionOutBid.Time = DateTime.Now; context.ParticipantActions.Add(participantActionOutBid); } } else if (auctionPrize.CustomBid != 0 && auctionPrize.CustomBid >= auctionPrizeToEdit.BidIncrement + auctionPrizeToEdit.CurrentBid) { if (auctionPrizeToEdit.CurrentBid == 0) { auctionPrizeToEdit.CurrentBid = auctionPrize.CustomBid; auction.TotalRaised += auctionPrize.CustomBid; auctionPrizeToEdit.CustomBid = 0; } else { auctionPrizeToEdit.CurrentBid = auctionPrize.CustomBid; auction.TotalRaised += auctionPrize.CustomBid; auctionPrizeToEdit.CustomBid = 0; ParticipantAction participantActionOutBid = new ParticipantAction(); participantActionOutBid.ParticipantId = auctionPrizeToEdit.TopParticipant; participantActionOutBid.Action = "You have been outbid on " + auctionPrizeToEdit.Name + "."; participantActionOutBid.Time = DateTime.Now; context.ParticipantActions.Add(participantActionOutBid); } } else { ModelState.AddModelError("", "You must bid more than the minimum bid increment"); return(View(auctionPrizeToEdit)); } ParticipantAction participantActionBid = new ParticipantAction(); participantActionBid.ParticipantId = participant.ParticipantId; participantActionBid.Action = "You have bid $" + auctionPrizeToEdit.CurrentBid + " on " + auctionPrizeToEdit.Name + "."; participantActionBid.Time = DateTime.Now; context.ParticipantActions.Add(participantActionBid); AddDataPoint(auction); auctionPrizeToEdit.TopParticipant = participant.ParticipantId; context.SaveChanges(); return(RedirectToAction("Participate", "Auction", new { id = auctionPrizeToEdit.AuctionId })); } catch { return(RedirectToAction("Index", "Participant")); } }