public void Get_Tournament_Invite() { var db = new DatabaseRepository("VictoriousEntities"); TournamentInviteModel invite = db.GetTournamentInvite("10000"); Assert.AreEqual("10000", invite.TournamentInviteCode); }
public void Update_Tournament_Invite() { var db = new DatabaseRepository("VictoriousEntities"); TournamentInviteModel invite = db.GetTournamentInvite("10006"); invite.TournamentInviteCode = "10055"; var result = db.UpdateTournamentInvite(invite); Assert.AreEqual(DbError.SUCCESS, result); }
public void AddTournamentInvite_Save() { TournamentInviteModel invite = new TournamentInviteModel() { DateCreated = DateTime.Today, DateExpires = DateTime.Today.AddDays(1), IsExpired = false, TournamentInviteCode = "1235", NumberOfUses = 0, TournamentID = service.GetAllTournaments()[0].TournamentID }; service.AddTournamentInvite(invite); var result = unitOfWork.Save(); Assert.AreEqual(true, result); }
public void Add_TournamentInvite() { var db = new DatabaseRepository("VictoriousEntities"); TournamentInviteModel invite = new TournamentInviteModel() { DateCreated = DateTime.Today, DateExpires = DateTime.Today.AddDays(1), IsExpired = false, TournamentInviteCode = "10011", NumberOfUses = 0, TournamentID = 2 }; var result = db.AddTournamentInvite(invite); Assert.AreEqual(DbError.SUCCESS, result); }
//TODO: Fix issue where tournamentCodes can collide and be repeatable. public bool Create(TournamentViewModel viewModel, Account account) { ApplyChanges(viewModel); // Exit the create if we detect there is an exception in the viewModel. if (viewModel.e != null) { SetupViewModel(viewModel); return(false); } Model.LastEditedOn = DateTime.Now; Model.LastEditedByID = account.Model.AccountID; Model.CreatedOn = DateTime.Now; Model.CreatedByID = account.Model.AccountID; // Generate the Tournament Invite Codes Model.InviteCode = Codes.GenerateInviteCode(); //Save the tournament First. services.Tournament.AddTournament(Model); AddUser(account, Permission.TOURNAMENT_CREATOR); //if (viewModel.BracketData != null) UpdateBrackets(); bool tournamentSave = services.Save(); // Create InviteModel TournamentInviteModel inviteModel = new TournamentInviteModel() { TournamentInviteCode = Model.InviteCode, DateCreated = DateTime.Now, TournamentID = Model.TournamentID, NumberOfUses = 0 }; // Add the Invite Model services.Tournament.AddTournamentInvite(inviteModel); bool TournamentInviteSave = services.Save(); return(tournamentSave && TournamentInviteSave); }
/// <summary> /// Deletes a single TournamentInvite from the database. /// </summary> /// <param name="tournamentInviteCode"> The invite code of the TournamentInvite to delete. </param> public void DeleteTournamentInvite(string tournamentInviteCode) { TournamentInviteModel tournamentInviteToDelete = GetTournamentInvite(tournamentInviteCode); unitOfWork.TournamentInviteRepo.DeleteEntity(tournamentInviteToDelete); }
/// <summary> /// Updates a single TournamentInvite. /// </summary> /// <param name="tournamentInvite"> The model of the TournamentInvite to be updated. </param> public void UpdateTournamentInvite(TournamentInviteModel tournamentInvite) { unitOfWork.TournamentInviteRepo.Update(tournamentInvite); }
/// <summary> /// Adds a single TournamentInvite to the database. /// </summary> /// <param name="tournamentInvite"> The model of the TournamentInvite that is being added. </param> public void AddTournamentInvite(TournamentInviteModel tournamentInvite) { unitOfWork.TournamentInviteRepo.Add(tournamentInvite); }