public ResultsForm(Contest contest) { InitializeComponent(); this._contest = contest; ShowResults(this._contest); this.Text = String.Format("Results by {0}", this._contest.Title); }
public AddContestForm(Contest contest = null) { InitializeComponent(); db = new DatabaseEntities(); _contest = contest; FillFields(); }
public ClientContestForm(User user, Contest contest) { InitializeComponent(); this._user = user; this._contest = contest; MakeTabs(); }
public ManageContest(Contest contest) { InitializeComponent(); this._contest = contest; this.Text = String.Format("{0}: {1}", this.Text, contest.Title); ShowTasks(); ShowUsers(); labelStartTime.Text = this._contest.StartTime.ToString(); labelEndTime.Text = this._contest.EndTime.ToString(); labelTitle.Text = this._contest.Title; }
public AddTaskForm(Contest contest, Task task = null) { InitializeComponent(); db = new DatabaseEntities(); this._contest = contest; this._task = task; if (this._task != null) { textBoxTitle.Text = this._task.Title; richTextBoxDescription.Text = this._task.Description; textBoxMark.Text = this._task.Mark.ToString(); } }
private void ShowResults(Contest contest) { using (var db = new DatabaseEntities()) { var tasks = db.Tasks.Where(t => t.ContestId == this._contest.Id); if (tasks == null) { MessageBox.Show("There are no result by this contest."); return; } var Tasks = tasks.Select(t => t.Id).ToList(); var tests = db.Tests.Where(t => Tasks.Contains(t.TaskId)).Select(t=>t.Id).ToList(); var results = db.Results.Where(t => tests.Contains(t.TaskId)).ToList(); foreach (var item in results) { } } }
public ActionResult Create(ContestBindingModel model) { if (this.ModelState != null && this.ModelState.IsValid) { Category category = this.ContestsData.Categories.Find(model.Category); bool isModelValid = CustomValidators.IsContestModelValid(category, model); if (!isModelValid) { this.AddToastMessage("Error", "Invalid data.", ToastType.Error); return View(model); } ICollection<User> voters = model.VotingType == VotingType.Closed ? this.GetUsers(model.Voters) : new HashSet<User>(); ICollection<User> participants = model.ParticipationType == ParticipationType.Closed ? this.GetUsers(model.Participants) : new HashSet<User>(); var contest = new Contest { Title = model.Title, Description = model.Description, OrganizatorId = this.UserProfile.Id, RewardType = model.RewardType, DeadlineType = model.DeadlineType, ParticipationType = model.ParticipationType, VotingType = model.VotingType, Voters = voters, WinnersCount = model.WinnersNumber, ParticipantsNumberDeadline = model.ParticipantsNumberDeadline, Participants = participants, DeadLine = model.DeadLine, CategoryId = model.Category }; if (model.Upload != null && model.Upload.ContentLength > 0) { var wallpaperPaths = Helpers.UploadImages.UploadImage(model.Upload, true); var wallpaperUrl = Dropbox.Download(wallpaperPaths[0]); var wallpaperThumbUrl = Dropbox.Download(wallpaperPaths[1], "Thumbnails"); contest.WallpaperPath = wallpaperPaths[0]; contest.WallpaperUrl = wallpaperUrl; contest.WallpaperThumbPath = wallpaperPaths[1]; contest.WallpaperThumbUrl = wallpaperThumbUrl; } else { contest.WallpaperUrl = AppKeys.WallpaperUrl; } this.ContestsData.Contests.Add(contest); this.ContestsData.SaveChanges(); this.AddToastMessage("Success", "Contest created.", ToastType.Success); return this.RedirectToAction("Details", "Users", routeValues: new { id = this.UserProfile.Id, area = "" }); } return this.View(); }
private void SendParticipantsNotification(Contest contest) { var hubContext = GlobalHost.ConnectionManager.GetHubContext<NotificationsHub>(); var participants = contest.Photos.GroupBy(f => f.OwnerId); foreach (var participant in participants) { var notification = new Notification { UserId = participant.Key, Message = string.Format("A contest you participated in was finalized. See contest result <a href=\"Winners/Details/{0}\">here</a>", contest.Id), Date = DateTime.Now, IsRead = false }; this.ContestsData.Notifications.Add(notification); hubContext.Clients.Group(participant.Key).receiveNotification(); } this.ContestsData.SaveChanges(); }
private void FillVoters(Contest contest, ICollection<string> votersIds, VotingType votingType) { if (votersIds == null || votingType == VotingType.Open) { contest.Voters.Clear(); } else { var voters = contest.Voters.ToList(); foreach (var voterId in votersIds) { if (contest.Voters.All(v => v.Id != voterId)) { var voter = this.ContestsData.Users.Find(voterId); contest.Voters.Add(voter); } } foreach (var voter in voters) { if (!votersIds.Contains(voter.Id)) { contest.Voters.Remove(voter); } } } }
private void FillPacticipants(Contest contest, ICollection<string> participantsIds, ParticipationType participationType) { if (participantsIds == null || participationType == ParticipationType.Open) { contest.Participants.Clear(); } else { var participants = contest.Participants.ToList(); foreach (var participantId in participantsIds) { if (contest.Participants.All(p => p.Id != participantId)) { var participant = this.ContestsData.Users.Find(participantId); contest.Participants.Add(participant); } } foreach (var participant in participants) { if (!participantsIds.Contains(participant.Id)) { contest.Participants.Remove(participant); } } } }