private void ContestsDataGrid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            // Check if any item is selected in contest ListView.
            if (ContestsDataGrid.SelectedIndex != -1)
            {
                ContestDetails contestDetails = (ContestDetails)ContestsDataGrid.SelectedItem;

                // Check if the contest has been created by the current user.
                if (Data.Instance.GetIfContestIsCreatedByCurrentUser(contestDetails.Id))
                {
                    this.Frame.Navigate(typeof(ContestPage), contestDetails);
                }
                else
                {
                    this.Frame.Navigate(typeof(VotingPage), contestDetails);
                }
            }
            else
            {
                ContentDialog errorMsg = new ContentDialog
                {
                    Title           = "Error",
                    Content         = "You must select a contest to see it's details.",
                    CloseButtonText = "OK"
                };

                App.ShowContentDialog(errorMsg, null);
            }
        }
Exemple #2
0
        /// <summary>
        /// This method retrieves the most up-to-date list of contests from the database.
        /// </summary>
        /// <returns>True if success, false otherwise.</returns>
        public async Task <bool> RefreshContestsAdminAsync()
        {
            // Load the contest that the users has part in from the Database
            string query = "SELECT id_contest, contest_name, descript, start_date, limit_date, voting_limit_date " +
                           "FROM contest_table";

            SqlCommand cmd = DBSqlHelper.Connection.CreateCommand();

            cmd.CommandText = query;

            // Execute query
            using (DbDataReader reader = await cmd.ExecuteReaderAsync())
            {
                // Check if contest exists
                if (reader.HasRows)
                {
                    ContestDetails.Clear();

                    while (await reader.ReadAsync())
                    {
                        ContestDetails contest = new ContestDetails((int)reader[0], reader[1].ToString(), reader[2].ToString(), (DateTime)reader[3], (DateTime)reader[4], (DateTime)reader[5], false, false, false);
                        ContestDetails.Add(contest);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            ContestToLoad = (ContestDetails)e.Parameter;

            await LoadContestDetailsAsync();
        }
        private void ContestGrid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            // Get which contest is associated with this grid.
            if (ContestsListView.SelectedItems.Count == 1)
            {
                ContestDetails contestDetails = (ContestDetails)ContestsListView.SelectedItems[0];

                this.Frame.Navigate(typeof(ContestPage), contestDetails);
            }
        }
        private void NotificationsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Get selected notification id.
            int notificationId = ((NotificationListItem)NotificationsListView.SelectedItem).Id;

            // Get which contest that this notification corresponds to.
            ContestDetails contestToSelect = ContestDetailsList.Single(x => x.Id == notificationId);

            // Select the project.
            ContestsListView.SelectedItem = contestToSelect;
        }
        public IActionResult Information()
        {
            ContestDetails contest = new ContestDetails();

            contest.flagNameOne  = HttpContext.Session.GetString("flagNameWithNameOne");
            contest.flagNameTwo  = HttpContext.Session.GetString("flagNameWithNameTwo");
            contest.startingTime = HttpContext.Session.GetString("StartingTime");
            PlayerRequest play = new PlayerRequest()
            {
                MatchId = Convert.ToInt32(HttpContext.Session.GetString("MatchId")),
                TourId  = Convert.ToInt32(HttpContext.Session.GetString("tourId"))
            };
            List <ContestDetailsResp> contestLst = _contestService.GetContestDetails(play);

            contest.ContestList = contestLst;
            return(View(contest));
        }
        private void Grid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            // Get which contest is associated with this grid.
            if (ContestsListView.SelectedItems.Count == 1)
            {
                ContestDetails contestDetails = (ContestDetails)ContestsListView.SelectedItems[0];

                // Check if the contest has been created by the current user.
                if (Data.Instance.GetIfContestIsCreatedByCurrentUser(contestDetails.Id))
                {
                    this.Frame.Navigate(typeof(ContestPage), contestDetails);
                }
                else
                {
                    this.Frame.Navigate(typeof(VotingPage), contestDetails);
                }
            }
        }
Exemple #8
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            LoadJudgesProgressRing.IsActive = true;
            LoadJudgesTextBlock.Visibility  = Visibility.Visible;

            LoadProjectsProgressRing.IsActive = true;
            LoadProjectsTextBlock.Visibility  = Visibility.Visible;

            LoadCriteriasProgressRing.IsActive = true;
            LoadCriteriasTextBlock.Visibility  = Visibility.Visible;

            ContestToLoad = (ContestDetails)e.Parameter;

            if (ContestToLoad != null)
            {
                EditingContest = true;
                await LoadContestDetailsAsync();
            }
            else
            {
                ContestToEdit = new Contest(-1, ContestToLoad, new ObservableCollection <Project>(), new ObservableCollection <JudgeMember>(), new ObservableCollection <Criteria>());
                ContestToEdit.ContestDetails = new ContestDetails();
            }

            LoadJudgesProgressRing.IsActive = false;
            LoadJudgesTextBlock.Visibility  = Visibility.Collapsed;

            LoadProjectsProgressRing.IsActive = false;
            LoadProjectsTextBlock.Visibility  = Visibility.Collapsed;

            LoadCriteriasProgressRing.IsActive = false;
            LoadCriteriasTextBlock.Visibility  = Visibility.Collapsed;

            Judges    = ContestToEdit.JudgeMembers;
            Projects  = ContestToEdit.Projects;
            Criterias = ContestToEdit.Criterias;

            JudgesListView.ItemsSource   = Judges;
            ProjectsListView.ItemsSource = Projects;
            CriteriaListView.ItemsSource = Criterias;
        }
        public IActionResult ContestDetail(string contestName)
        {
            ContestDetails contest = new ContestDetails();

            contest.flagNameOne  = HttpContext.Session.GetString("flagNameWithNameOne");
            contest.flagNameTwo  = HttpContext.Session.GetString("flagNameWithNameTwo");
            contest.startingTime = HttpContext.Session.GetString("StartingTime");

            ContestRequest play = new ContestRequest()
            {
                MatchId   = Convert.ToInt32(HttpContext.Session.GetString("MatchId")),
                TourId    = Convert.ToInt32(HttpContext.Session.GetString("tourId")),
                SectionId = ContestHelper.GetContestSection(contestName)
            };
            List <ContestDetailsResp> contestLst = _contestService.GetFullContestDetails(play);

            contest.ContestAdditionalLst = contestLst[0].AddonList;
            return(View(contest));
        }
Exemple #10
0
        /// <summary>
        /// This method retrieves the most up-to-date list of contests from the database.
        /// </summary>
        /// <returns>True if success, false otherwise.</returns>
        public async Task <bool> RefreshContestsAsync()
        {
            // Load the contest that the users has part in from the Database
            string query = "SELECT id_contest, contest_name, descript, start_date, limit_date, voting_limit_date " +
                           "FROM contest_table " +
                           "WHERE id_contest IN( " +
                           "SELECT id_contest FROM contest_juri_table contest " +
                           "WHERE id_user = @id_user)";

            SqlCommand cmd = DBSqlHelper.Connection.CreateCommand();

            cmd.CommandText = query;

            SqlParameter sqlUserId = new SqlParameter("id_user", SqlDbType.Int);

            sqlUserId.Value = this.LoggedInUser.Id;
            cmd.Parameters.Add(sqlUserId);

            // Execute query
            using (DbDataReader reader = await cmd.ExecuteReaderAsync())
            {
                // Check if contest exists
                if (reader.HasRows)
                {
                    ContestDetails.Clear();

                    while (await reader.ReadAsync())
                    {
                        ContestDetails contest = new ContestDetails((int)reader[0], reader[1].ToString(), reader[2].ToString(), (DateTime)reader[3], (DateTime)reader[4], (DateTime)reader[5], false, false, false);
                        ContestDetails.Add(contest);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        private void ShowContestDetailsButton_Click(object sender, RoutedEventArgs e)
        {
            // Get which contest is associated with this grid.
            if (ContestsListView.SelectedItems.Count == 1)
            {
                ContestDetails contestDetails = (ContestDetails)ContestsListView.SelectedItems[0];


                this.Frame.Navigate(typeof(ContestPage), contestDetails);
            }
            else
            {
                ContentDialog errorMsg = new ContentDialog
                {
                    Title           = "Error",
                    Content         = "You must select a contest to view it's details!",
                    CloseButtonText = "OK"
                };

                App.ShowContentDialog(errorMsg, null);
            }
        }
        public ActionResult Index(FormCollection frm)
        {
            var usermanager = IdentityTools.NewUserManager();
            //aktif kullanici
            ApplicationUser appuser = usermanager.FindByName(User.Identity.Name);
            var             bonus   = repoBonus.GetAll(x => x.UserId == appuser.Id && x.IsDeleted == false);
            //yarışma id
            int conid = Convert.ToInt16(frm["conid"]);

            var contest = repoCon.Get(x => x.Id == conid);
            //yarışma soruları vvar
            List <ContestDetails> cde = repoConDeta.GetAll(k => k.ContestId == conid).ToList();
            //yarışma soruların id ekrandan geldi

            int id = Convert.ToInt16(frm["id"]);
            //soru

            ContestDetails cd = repoConDeta.Get(k => k.Id == id);

            string cvp    = frm["answer"].ToString();
            string numara = frm["num"].ToString();

            if (bonus != null)
            {
                foreach (var item in bonus)
                {
                    if (item.WheelValueId == 17 || item.WheelValueId == 10)
                    {
                        ViewBag.Saniye = "+";
                    }
                }
            }

            if (cd.TAns == cvp)
            {
                if ((contest.QuesCount).ToString() == numara)
                {
                    var lasttrans = repoUserTrans.GetAll().OrderByDescending(x => x.Date).Take(1).FirstOrDefault();
                    lasttrans.Prize   = contest.Prize;
                    lasttrans.Balance = repoUserTrans.TotalBalance(appuser.Id) + contest.Prize;
                    repoUserTrans.Update();
                    return(View("Win"));
                }

                return(View(cde[Convert.ToInt16(numara)]));
            }
            else
            {
                if (bonus != null)
                {
                    foreach (var item in bonus)
                    {
                        if (item.WheelValueId == 9 && item.IsDeleted == false)
                        {
                            item.IsDeleted = true;
                            repoBonus.Update();
                            ViewBag.Joker = "Yanlış cevap jokeri kullanıldı";
                            return(View(cde[Convert.ToInt16(numara)]));
                        }
                    }
                }
                return(View("Loose"));
            }
        }
Exemple #13
0
        /// <summary>
        /// Gets the contest with all details filled out from the database.
        /// </summary>
        /// <param name="id">The contest id to retrieve.</param>
        /// <returns>The contest object if it exists, null otherwise.</returns>
        public async Task <Contest> GetContest(int id)
        {
            // Varaiables declaration.
            Contest contest;

            SqlCommand cmd;

            SqlParameter sqlContestId, sqlUserId;

            string query;

            ObservableCollection <Project>     contestProjects  = new ObservableCollection <Project>();
            ObservableCollection <JudgeMember> contestJudges    = new ObservableCollection <JudgeMember>();
            ObservableCollection <Criteria>    contestCriterias = new ObservableCollection <Criteria>();

            // Get the contest details from the database.
            query = "SELECT * " +
                    "FROM contest_table " +
                    "WHERE id_contest = @id_contest";

            cmd             = DBSqlHelper.Connection.CreateCommand();
            cmd.CommandText = query;

            sqlUserId       = new SqlParameter("id_user", SqlDbType.Int);
            sqlUserId.Value = LoggedInUser.Id;
            cmd.Parameters.Add(sqlUserId);

            sqlContestId       = new SqlParameter("id_contest", SqlDbType.Int);
            sqlContestId.Value = id;
            cmd.Parameters.Add(sqlContestId);

            using (DbDataReader reader = await cmd.ExecuteReaderAsync())
            {
                // Check if the contest exists.
                if (reader.HasRows)
                {
                    await reader.ReadAsync();

                    ContestDetails contestDetails = new ContestDetails(id, reader.GetString(1), reader.GetString(2), reader.GetDateTime(3), reader.GetDateTime(4), reader.GetDateTime(5), false, false, false);

                    contest = new Contest(id, contestDetails, new ObservableCollection <Project>(), new ObservableCollection <JudgeMember>(), new ObservableCollection <Criteria>());
                }
                else
                {
                    return(null);
                }
            }

            // Get the contest project list.
            query = "SELECT id_project, name, descript, id_category, project_year FROM project_table WHERE id_contest = @id_contest ORDER BY id_project";

            cmd             = DBSqlHelper.Connection.CreateCommand();
            cmd.CommandText = query;

            sqlContestId       = new SqlParameter("id_contest", SqlDbType.Int);
            sqlContestId.Value = id;
            cmd.Parameters.Add(sqlContestId);

            using (DbDataReader reader = await cmd.ExecuteReaderAsync())
            {
                // Check if there's any projects in the contest.
                if (reader.HasRows)
                {
                    // Read every project, and store it in a list.
                    while (await reader.ReadAsync())
                    {
                        Project project = new Project(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), new Category(reader.GetInt32(3), ""), reader.GetInt32(4));

                        contestProjects.Add(project);
                    }
                }
            }

            // Cycle through all projects and get the full category.
            foreach (Project project in contestProjects)
            {
                foreach (Category category in this.Categories)
                {
                    // Check if the project category id is the same as the category id.
                    if (project.Category.Id == category.Id)
                    {
                        // Assign the category to the project category.
                        project.Category = category;
                    }
                }

                // Query the database to get the project promoters.
                query = "SELECT id_promoter, name, date_of_birth FROM promoter_table WHERE id_project = @id_project";

                cmd             = DBSqlHelper.Connection.CreateCommand();
                cmd.CommandText = query;

                cmd.Parameters.Add(new SqlParameter("@id_project", project.Id));

                project.Promoters = new ObservableCollection <Promoter>();

                using (DbDataReader reader = await cmd.ExecuteReaderAsync())
                {
                    // Check if there's any projects in the contest.
                    if (reader.HasRows)
                    {
                        // Read every project, and store it in a list.
                        while (await reader.ReadAsync())
                        {
                            Promoter promoter = new Promoter(reader.GetInt32(0), reader.GetString(1), reader.GetDateTime(2));

                            project.Promoters.Add(promoter);
                        }
                    }
                }
            }

            contest.Projects = contestProjects;

            // Get the contest judge list.
            query = "SELECT id_user, president FROM contest_juri_table WHERE id_contest = @id_contest ORDER BY id_user";

            cmd             = DBSqlHelper.Connection.CreateCommand();
            cmd.CommandText = query;

            sqlContestId       = new SqlParameter("id_contest", SqlDbType.Int);
            sqlContestId.Value = id;
            cmd.Parameters.Add(sqlContestId);

            using (DbDataReader reader = await cmd.ExecuteReaderAsync())
            {
                // Check if there's any judges in the contest.
                if (reader.HasRows)
                {
                    // Read every judge, and store it in a list.
                    while (await reader.ReadAsync())
                    {
                        // Check if it's not the president.
                        if (!reader.GetBoolean(1))
                        {
                            JudgeMember judge = new JudgeMember(reader.GetInt32(0), "");

                            contestJudges.Add(judge);
                        }
                    }
                }
            }

            // Cycle through all judges and get the full details.
            foreach (JudgeMember contestJudge in contestJudges)
            {
                foreach (JudgeMember judge in this.JudgeMembers)
                {
                    // Check if the contest judge id is the same as the stored judge id.
                    if (contestJudge.Id == judge.Id)
                    {
                        // Assign the judge details to the contest judge.
                        contestJudge.Name = judge.Name;
                    }
                }
            }

            contest.JudgeMembers = contestJudges;

            // Get the contest criteria list.
            query = "SELECT id_criteria FROM contest_criteria_table WHERE id_contest = @id_contest ORDER BY id_criteria";

            cmd             = DBSqlHelper.Connection.CreateCommand();
            cmd.CommandText = query;

            sqlContestId       = new SqlParameter("id_contest", SqlDbType.Int);
            sqlContestId.Value = id;
            cmd.Parameters.Add(sqlContestId);

            using (DbDataReader reader = cmd.ExecuteReader())
            {
                // Check if there's any criterias in the contest.
                if (reader.HasRows)
                {
                    // Read every criteria, and store it in a list.
                    while (reader.Read())
                    {
                        Criteria criteria = new Criteria(reader.GetInt32(0), "", "");

                        contestCriterias.Add(criteria);
                    }
                }
            }

            // Refresh the criteria list.
            await this.RefreshCriteriasAsync();

            // Cycle through all criteria and get the full details.
            foreach (Criteria contestCriteria in contestCriterias)
            {
                foreach (Criteria criteria in this.Criterias)
                {
                    // Check if the criteria judge id is the same as the stored judge id.
                    if (contestCriteria.Id == criteria.Id)
                    {
                        // Assign the criteria details to the contest criteria.
                        contestCriteria.Name        = criteria.Name;
                        contestCriteria.Description = criteria.Description;
                    }
                }
            }

            contest.Criterias = contestCriterias;

            return(contest);
        }
        public ActionResult Create([Bind(Include = "Id,ConName,ConTypeId,QuesCount,Level,Price,Prize,Date,IsDeleted")] Contest contest)
        {
            switch (contest.ConTypeId)
            {
            case 2:
                contest.Picture = "/img/genelkültür.jpg";
                break;

            case 4:
                contest.Picture = "/img/cografyayarisma.jpg";
                break;

            case 5:
                contest.Picture = "/img/sanat.jpg";
                break;

            case 6:
                contest.Picture = "/img/tarih.jpg";
                break;

            case 7:
                contest.Picture = "/img/spor.jpg";
                break;

            case 8:
                contest.Picture = "/img/genelyarisma.jpg";
                break;
            }
            if (ModelState.IsValid)
            {
                ContestDetails cd      = new ContestDetails();
                ContestType    contype = repoConType.Get(x => x.Id == contest.ConTypeId);
                string         type    = contype.TypeName;
                db.Contests.Add(contest);
                for (int i = 0; i < contest.QuesCount; i++)
                {
                    Questions qe = new Questions();
                    if (type == "Genel")
                    {
                        qe = db.Questions.Where(u => u.IsDeleted == false && u.Level == 1).OrderBy(u => Guid.NewGuid()).Take(1).FirstOrDefault();
                    }

                    else
                    {
                        qe = db.Questions.Where(u => u.IsDeleted == false && u.QType == type && u.Level == 1).OrderBy(u => Guid.NewGuid()).Take(1).FirstOrDefault();
                    }

                    cd.ContestId   = contest.Id;
                    cd.QuesId      = qe.Id;
                    cd.ContestType = type;
                    cd.QuesNum     = (i + 1);
                    cd.Question    = qe.Question;
                    cd.Ans1        = qe.Ans1;
                    cd.Ans2        = qe.Ans2;
                    cd.Ans3        = qe.Ans3;
                    cd.Ans4        = qe.Ans4;
                    cd.TAns        = qe.TrueAns;
                    cd.IsDeleted   = false;
                    db.ContestDetails.Add(cd);
                    qe.IsDeleted = true;
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            return(View(contest));
        }