void TerminateAuction(Auction auction) { auction.Status = EnumTypes.AuctionStatus.Completed.ToString(); auction.TotalSoldCoins = 546; _context.Update(auction); if (!auction.IsManualScheduled) { AddNewAuction(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,StartTime,EndTime,TotalPoolCoins,TotalSoldCoins, Status")] Auction auction) { SetSessionValues(); if (IsLoggedOut()) { return(LogOut()); } if (id != auction.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(auction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuctionExists(auction.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(auction)); }
public async Task <IActionResult> CancelBid(int id) { IDbContextTransaction transaction = _context.Database.BeginTransaction(); try { var BidSent = await _context.BidsSent.FindAsync(id); var BidReq = await _context.BidsRequest.FirstOrDefaultAsync(x => x.BidSentId == BidSent.Id); BidSent.BidStatus = EnumTypes.BidRequestStatus.Cancelled.ToString(); BidReq.BidStatus = EnumTypes.BidRequestStatus.Cancelled.ToString(); _context.Update(BidSent); _context.Update(BidReq); await _context.SaveChangesAsync(); transaction.Commit(); } catch { transaction.Rollback(); } return(RedirectToAction(nameof(SentBid))); }
public async Task MatureCoinForId(int id, bool allCoins = false) { var coins = await _context.Coins.FindAsync(id); coins.MaturityStatus = EnumTypes.CoinsMaturityStatus.Matured.ToString(); var wallet = _context.Wallets.FirstOrDefault(u => u.UserId == coins.UserId); wallet.TotalCoins += coins.TotalCoins; _context.Update(wallet); _context.Update(coins); if (!allCoins) { await _context.SaveChangesAsync(); } }
private void MatureCoins() { var users = _context.Users.ToList(); foreach (var usr in users) { var coins = _context.Coins.Where(c => c.UserId == usr.UserId && c.MaturityStatus == EnumTypes.CoinsMaturityStatus.Pending.ToString()); foreach (var c in coins) { if (true)//DateTime.Now.CompareTo(c.MaturityDate) >= 0) { c.MaturityStatus = EnumTypes.CoinsMaturityStatus.Matured.ToString(); var wallet = _context.Wallets.FirstOrDefault(u => u.UserId == c.UserId); wallet.TotalCoins += c.TotalCoins; _context.Update(wallet); _context.Update(c); } } } _context.SaveChangesAsync(); }
public async Task <IActionResult> Edit(int id, UserViewModel userVM) { SetSessionValues(); if (IsLoggedOut()) { return(Logout()); } if (id != userVM.User.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userVM.User); _context.Update(userVM.Wallet); _context.Update(userVM.Bank); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(userVM.User.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userVM)); }