public ActionResult AjoutParticipant() { // Liste des participants de la compétition int idC = Convert.ToInt32(Session["idComp"]); DCJoueur dCJoueur = new DCJoueur(); Joueur participant = new Joueur(); Joueur joueur = new Joueur(); List <VMParticipant> listeParticipant = new List <VMParticipant>(); foreach (Joueur j in participant.GetListJoueurComp(idC)) { VMParticipant mParticipant = new VMParticipant(); joueur = dCJoueur.GetJoueur(j.Id); mParticipant.Id = joueur.Id; mParticipant.Nom = joueur.Nom; mParticipant.Prenom = joueur.Prenom; mParticipant.National = joueur.National; mParticipant.Position = Convert.ToString(dCJoueur.GetPositionComp(joueur.Id, idC)); if (mParticipant.Position == "100") { mParticipant.Position = "Pas classé(e)"; } listeParticipant.Add(mParticipant); } ViewBag.listeParticipant = listeParticipant; return(View()); }
//ANCHOR Accepts/Denies a participants access to a challenge. internal VMParticipant AcceptOrDenyParticipant(VMParticipant participant) { string sql = @" UPDATE participants SET pendingAddToChallenge = @PendingAddToChallenge, addedToChallenge = @AddedToChallenge WHERE id = @Id;"; _db.Execute(sql, participant); return(participant); }
public async Task <ActionResult <VMParticipant> > AcceptOrDenyParticipant([FromBody] VMParticipant participant) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); VMParticipant edited = _ps.AcceptOrDenyParticipant(userInfo.Id, participant); return(Ok(edited)); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
//ANCHOR Accepts/Denies a participant's entry request into a challenge //ANCHOR Checks if user is creator of challenge //ANCHOR Checks if Challenge exists //ANCHOR Checks if Participant exists internal VMParticipant AcceptOrDenyParticipant(string userId, VMParticipant participant) { Participant original = _repo.GetSelectedParticipant(participant.Id); if (original == null) { throw new Exception("Invalid Participant Id"); } if (original.AddedToChallenge == true) { throw new Exception("This participant has already been added"); } Challenge challenge = _cs.GetById(participant.ChallengeId.ToString()); if (challenge.HasStarted == true) { throw new Exception("This Challenge has already started"); } if (challenge.CreatorId != userId) { throw new Exception("You Do Not Have The Authority For This"); } if (original.PendingAddToChallenge == false && original.AddedToChallenge == false) { throw new Exception("User Already Denied Access"); } if (original.PendingAddToChallenge == false && original.AddedToChallenge == true) { throw new Exception("User Already Granted Access"); } participant.ProfileId = original.ProfileId; participant.ChallengeId = original.ChallengeId; if (participant.AcceptOrDeny == 0) { participant.PendingAddToChallenge = false; participant.AddedToChallenge = false; return(_repo.AcceptOrDenyParticipant(participant)); } participant.PendingAddToChallenge = false; participant.AddedToChallenge = true; //This needs to create all the daily sheets based on challenge start date and duration. _dps.CreateSheets(participant, challenge); return(_repo.AcceptOrDenyParticipant(participant)); }