// // ────────────────────────────────────────────────────────────────────────── // :::::: C O N S T R U C T O R S : : : : : : : : // ────────────────────────────────────────────────────────────────────────── // /// <summary> /// Constructor /// </summary> /// <param name="bet">The fb</param> /// <param name="_context">The database context</param> /// <param name="includeResult">True to include the result of the match, false otherwise</param> public GroupBet(Data.Models.FootballBet bet, Data.ApplicationDBContext _context, bool includeResult) { _context.Entry(bet).Reference("MatchDay").Load(); _context.Entry(bet.MatchDay).Reference("Competition").Load(); _context.Entry(bet).Reference("type").Load(); _context.Entry(bet).Reference("typePay").Load(); _context.Entry(bet.MatchDay).Reference("HomeTeam").Load(); _context.Entry(bet.MatchDay).Reference("AwayTeam").Load(); this.bet = bet.id.ToString(); this.competition = bet.MatchDay.Competition.name; this.betName = bet.MatchDay.HomeTeam.name + " vs " + bet.MatchDay.AwayTeam.name; this.matchdayDate = bet.MatchDay.date; this.typeBet = new NameWinRate(bet.type); this.typePay = new NameWinRate(bet.typePay); this.minBet = bet.minBet; this.maxBet = bet.maxBet; this.lastBetTime = bet.dateLastBet; if (Util.CheckBetType.isJackpot(bet, _context)) { this.usersJoined = bet.usersJoined; } if (includeResult) { this.firstHalfHomeGoals = bet.MatchDay.firstHalfHomeGoals; this.firstHalfAwayGoals = bet.MatchDay.firstHalfAwayGoals; this.secondHalfHomeGoals = bet.MatchDay.secondHalfHomeGoals; this.secondHalfAwayGoals = bet.MatchDay.secondHalfAwayGoals; this.fullTimeHomeGoals = bet.MatchDay.fullTimeHomeGoals; this.fullTimeAwayGoals = bet.MatchDay.fullTimeAwayGoals; } }
/// <summary> /// Reset the delete account petition /// </summary> /// <param name="u">The user who doesn't want to delete the account</param> /// <param name="dbContext">The database context</param> public static void reset(Data.Models.User u, Data.ApplicationDBContext dbContext) { try { u.dateDeleted = null; dbContext.SaveChanges(); } catch (Exception) { } }
// // ────────────────────────────────────────────────────────────────────────── // :::::: C O N S T R U C T O R S : : : : : : : : // ────────────────────────────────────────────────────────────────────────── // /// <summary> /// Constructor /// </summary> /// <param name="dm">The dm conversation</param> /// <param name="userId">The id of the caller</param> /// <param name="isAdmin">True if the caller is an admin, false otherwise</param> /// <param name="_context">The database context</param> public DMTitle(Data.Models.DirectMessageTitle dm, Guid userId, bool isAdmin, Data.ApplicationDBContext _context) { _context.Entry(dm).Reference("receiver").Load(); _context.Entry(dm).Reference("Sender").Load(); Data.Models.User recv = dm.receiver; Data.Models.User load = userId == recv.id ? dm.Sender : recv; this.id = dm.id.ToString(); this.receiver = load.nickname; this.emailReceiver = isAdmin ? load.email : null; this.lastUpdate = dm.lastUpdate; this.closed = dm.closed; this.unreadMessages = isAdmin ? dm.unreadMessagesForAdmin : dm.unreadMessagesForUser; this.title = dm.title; }