public List <ResultsDTO> GetUsersRole()
        {
            SqlConnection     sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
            List <ResultsDTO> list    = new List <ResultsDTO>();

            using (sqlconn)
            {
                using (SqlCommand cmd = new SqlCommand("getUserRoles", sqlconn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    sqlconn.Open();

                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            ResultsDTO userCampaign = new ResultsDTO
                            {
                                UserId = rdr["UserId"].ToString(),
                                RoleId = rdr["UserId"].ToString()
                            };
                            list.Add(userCampaign);
                        }
                    }
                }
            }
            return(list);
        }
        public IEnumerable <ResultsDTO> GetAllResults()
        {
            List <ResultsDTO> rList = new List <ResultsDTO>();

            using (SqlConnection conn = new SqlConnection(dbConnection))
            {
                using (SqlCommand cmd = new SqlCommand("usp_GetAllResults", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();
                    SqlDataReader dataReader = cmd.ExecuteReader();
                    while (dataReader.Read())
                    {
                        ResultsDTO rDTO = new ResultsDTO();
                        try
                        {
                            rDTO.PlayerId = Convert.ToInt32(dataReader["PlayerId"].ToString());
                        }
                        catch
                        {
                            rDTO.PlayerId = 0;
                        }
                        rDTO.Results = Convert.ToInt32(dataReader["Result"].ToString());
                        rDTO.Time    = dataReader["Time"].ToString();
                        rDTO.Clicks  = Convert.ToInt32(dataReader["Clicks"].ToString());
                        rList.Add(rDTO);
                    }
                }
                conn.Close();
            }
            return(rList);
        }
        public bool addResult(ResultsDTO rDTO)
        {
            DatabaseManager addOneResult = new DatabaseManager();
            bool            isSuccesful  = addOneResult.AddResult(rDTO);

            return(isSuccesful);
        }
Exemple #4
0
 public SearchModel(ResultsDTO dto)
 {
     this.jobId            = dto.jobId;
     this.applicationId    = dto.applicationId;
     this.contractCode     = dto.contractCode;
     this.contractDesc     = dto.contractDesc;
     this.districtCode     = dto.districtCode;
     this.districtDesc     = dto.districtDesc;
     this.jobAddress       = dto.jobAddress;
     this.districtAddress  = dto.districtAddress;
     this.districtPostCode = dto.districtPostCode;
 }
Exemple #5
0
        public ActionResult AddResultsToEncounter([FromBody] ResultsDTO results)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                encounterBusinessLogic.AddResults(results.Positions, results.EncounterId);
                return(Ok(new ResponseOkDTO()));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
        public bool AddResult(ResultsDTO rDTO)
        {
            bool isSuccessful = true;

            using (SqlConnection conn = new SqlConnection(dbConnection))
            {
                using (SqlCommand cmd = new SqlCommand("usp_InsertResult", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@PlayerId", rDTO.PlayerId);
                    cmd.Parameters.AddWithValue("@Result", rDTO.Results);
                    cmd.Parameters.AddWithValue("@Time", rDTO.Time);
                    cmd.Parameters.AddWithValue("@Clicks", rDTO.Clicks);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                conn.Close();
            }
            return(isSuccessful);
        }
Exemple #7
0
        public IActionResult Upcoming(string search)
        {
            ViewData["CurrentFilter"] = search;
            var all       = _competitionService.GetUpcomingEvents(null, false);
            var athletics = _competitionService.GetUpcomingEvents(AthleticsId, false);
            var cycling   = _competitionService.GetUpcomingEvents(CyclingId, false);
            var other     = _competitionService.GetUpcomingEvents(0, false);

            if (!String.IsNullOrEmpty(search))
            {
                var searchToUpper = search.ToUpper();
                all       = all.Where(u => u.CompetitionInstanceName.ToUpper().Contains(searchToUpper));
                athletics = athletics.Where(u => u.CompetitionInstanceName.ToUpper().Contains(searchToUpper));
                cycling   = cycling.Where(u => u.CompetitionInstanceName.ToUpper().Contains(searchToUpper));
                other     = other.Where(u => u.CompetitionInstanceName.ToUpper().Contains(searchToUpper));
            }
            var model = new ResultsDTO {
                All = all, Athletics = athletics, Cycling = cycling, Other = other
            };

            return(View(model));
        }
Exemple #8
0
        /// <summary>
        /// Returns the partial view of the results
        /// </summary>
        /// <param name="objAvailabilityDTO">AvailabilityDTO of the users paramaters for searching</param>
        /// <returns>Partial View</returns>
        // [HttpPost]
        public PartialViewResult GetResults(AvailabilityDTO objAvailabilityDTO)
        {
            //Gets all rooms with the same room type that have no bookings between the selected dates
            var temprooms = context.Rooms.Where(r => r.RoomTypeId == objAvailabilityDTO.RoomTypeId).Where(m => m.Reservations.All(r => r.Depature <= objAvailabilityDTO.Arrival || r.Arrival >= objAvailabilityDTO.Departure));

            List <Room> rooms = new List <Room>();

            foreach (Room r in temprooms)
            {
                rooms.Add(r);
            }

            ResultsDTO results = new ResultsDTO {
                AvailableRooms = rooms, Arrival = objAvailabilityDTO.Arrival, Departure = objAvailabilityDTO.Departure
            };

            if (!results.AvailableRooms.Any())
            {
                ViewBag.Any = "There is no available rooms during this time! ";
            }

            //returns the partial view to be displayed with Ajax dynamically
            return(PartialView("_Results", results));
        }
        // GET: Results/ResultsChart
        public ActionResult ResultsChart()
        {
            String uId = User.Identity.GetUserId();        // get logged in users Id

            ResultsViewModel rVM = new ResultsViewModel(); // get all the user roles


            ResultsDTO results = new ResultsDTO(); //


            List <ResultsDTO> resultsDTO = rVM.GetUsersRole();

            bool found = false;

            foreach (var result in resultsDTO)
            {
                if (uId != result.UserId)
                {
                    found = true;
                }
            }
            CampaignViewModel  camVM    = new CampaignViewModel(); // get all the campaign
            List <CampaignDTO> campaign = new List <CampaignDTO>();

            campaign = camVM.GetAllCampaigns();

            ChartsViewModel   cVM         = new ChartsViewModel();
            RegisterViewModel userDetails = cVM.GetUserDetailsById(uId);  // get signed in users details

            List <string> usersCountryCampainglist = new List <string>(); // get the campaigns name from the list campaings model and add them to string list

            if (found == true)                                            // if the user exist
            {
                foreach (var cam in campaign)
                {
                    if (userDetails.Country == cam.Country)
                    {
                        if (!usersCountryCampainglist.Contains(cam.Description.ToString()))
                        {
                            usersCountryCampainglist.Add(cam.Description);
                        }
                    }
                }
            }
            //bool isEmpty = !results.Any();
            bool isEmpty = !usersCountryCampainglist.Any();

            if (!isEmpty) // check if the list is not null than add the values to the object , else redirect the user that there are no campaigns in the country
            {
                results.Campagin  = usersCountryCampainglist.First();
                results.Campaigns = usersCountryCampainglist;
                ViewBag.Campaign  = usersCountryCampainglist.First();         // get the first country for the Campaigns
                var collectedCampaign = usersCountryCampainglist.First();     // get the first country for the Campaigns
                CampaignDashBoardList(collectedCampaign);                     // default draw of the data
                return(View("~/Views/Results/ResultsChart.cshtml", results)); // return with the values to view.
            }
            else
            {
                return(View("~/Views/Results/NotFound.cshtml")); // no ca
            }
        }
Exemple #10
0
        public IActionResult HandleButtonClick(int index)
        {
            // set the size of the board
            int size = (int)Math.Sqrt(cells.Length);
            // selects the cell out of the cell list
            //Cell cell = cellList.ElementAt(index);
            MouseEventArgs me   = new MouseEventArgs();
            var            User = HttpContext.Session.GetInt32("_Id");

            UserID = (int)User;
            //if (cellList.ElementAt(index).visited == false)
            //{
            if (me.Button.Equals(0))
            {
                cellList.ElementAt(index).flagged = false;
                clickCount++;
                // Left click
                // check if the cell is a bomb
                if (cellList.ElementAt(index).live != true && cellList.ElementAt(index).liveNeighbors <= 1)
                {
                    // Call the Flood Fill method
                    cb.floodFill(cells, cellList.ElementAt(index).row, cellList.ElementAt(index).col, size);
                }
                else if (cellList.ElementAt(index).liveNeighbors > 1)
                {
                    cellList.ElementAt(index).visited = true;
                }
                else if (cellList.ElementAt(index).live == true)
                {
                    // set visited to true to reveal the bomb
                    cellList.ElementAt(index).visited = true;
                    lose    = true;
                    endTime = cb.stopTimer();
                    ResultData resultData = new ResultData();
                    ResultsDTO rDTO       = new ResultsDTO(UserID, 0, endTime, clickCount);
                    resultData.addResult(rDTO);
                }
            }
            // checks for win condition
            if (cb.boardCheck(cells, size) == true)
            {
                win     = true;
                endTime = cb.stopTimer();
                ResultData resultData = new ResultData();
                ResultsDTO rDTO       = new ResultsDTO(UserID, 1, endTime, clickCount);
                resultData.addResult(rDTO);
            }
            if (lose == true)
            {
                // reveals the board after a loss
                cb.revealBoard(cells, size);
                // Lose statement
                ViewBag.win = "BOOM! You set off a bomb! You Lose!";
            }
            else if (win == true)
            {
                cb.revealBoard(cells, size);
                // win statement
                ViewBag.win = "All Bomb Locations Identified! You Win!";
            }
            //}
            return(View("Board", cellList));
        }