public void Update(ContestParticipant participant) { ContestParticipant old = Get(participant.Id); int index = list.IndexOf(old); list[index] = participant; }
public static List <ContestParticipant> GetForumParticipants(Contest contest) { try { var users = TableHelper.GetListFromQuery <Member>(@"WHERE Users.AccountStatusInt = 9 OR Users.AccountStatusInt = 1 OR Users.AccountStatusInt = 10"); var participants = new List <string>(); foreach (Member user in users) { if (contest.CanMemberParticipate(user, true)) { participants.Add(user.Name); } } DataTable result; using (var bridge = ParserPool.Acquire(Database.Forum)) { result = bridge.Instance.ExecuteRawCommandToDataTable(@"select COUNT(m.MessageID), us.Name from yaf_Message m INNER JOIN yaf_Topic t ON t.TopicID = m.TopicID INNER JOIN yaf_User us ON us.UserID = m.UserID INNER JOIN yaf_Forum f ON f.ForumID = t.ForumID WHERE m.IsDeleted = 0 AND m.IsApproved = 1 AND m.Posted > '" + contest.DateStart.ToDBString() + "' AND m.Posted < '" + contest.DateEnd.ToDBString() + "' AND f.ForumID in (select ForumId from ForumContests where ContestId = " + contest.Id + @") GROUP BY us.Name;"); } List <ContestParticipant> list = new List <ContestParticipant>(result.Rows.Count); foreach (DataRow row in result.Rows) { ContestParticipant participant = new ContestParticipant(); participant.Username = (string)row[1]; if (participants.Contains(participant.Username)) { participant.Points = new Money(Convert.ToDecimal(row[0])); participant.LatestAction = DateTime.Now.Zero(); participant.ContestId = contest.Id; list.Add(participant); } } return(list); } catch (Exception ex) { throw ex; } }
public ActionResult Submit([FromBody] ContestModel contestModel) { SerialNumber serialNumber = serialNumberRepository.Get(contestModel.SerialNumber); if (serialNumber == null) { return(BadRequest("Bad serial number")); } ContestParticipant participant = contestParticipantRepository.Get(contestModel.Email, contestModel.FirstName, contestModel.LastName); if (participant == null && serialNumber.ContestParticipantId != null) { return(BadRequest("Bad serial number")); } if (participant == null) { participant = new ContestParticipant { Email = contestModel.Email, FirstName = contestModel.FirstName, LastName = contestModel.LastName }; contestParticipantRepository.Create(participant); } if (serialNumber.ContestParticipantId == null) { serialNumber.ContestParticipantId = participant.Id; serialNumber.Redeemed = 1; serialNumberRepository.Update(serialNumber); } else { bool found = false; foreach (SerialNumber sn in participant.SerialNumbers) { if (sn.Number != contestModel.SerialNumber) { continue; } if (sn.Redeemed >= 2) { return(BadRequest("Serial number is already redemed 2 times")); } found = true; sn.Redeemed++; contestParticipantRepository.Update(participant); } if (!found) { return(BadRequest("Bad serial number")); } } return(new OkResult()); }
public void Update(ContestParticipant participant) { contestParticipants.Update(participant); context.SaveChanges(); }
public void Create(ContestParticipant participant) { contestParticipants.Add(participant); context.SaveChanges(); }
public void Create(ContestParticipant participant) { list.Add(participant); }