Example #1
0
 public IActionResult Post([FromBody] Event @event)
 {
     try
     {
         if (@event == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _eventRepository.Add(@event);
         if (result)
         {
             _logger.LogInformation("Event Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Event has Failed to Add. Event - {0}", @event);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Event failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error Event failed to add . Error - {0} , Data - {1}", e.Message, @event);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Event Failed to Add.")));
     }
 }
        public IActionResult GetCountryBasedOnTournament(int?tournamentId)
        {
            try
            {
                if (!tournamentId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("tournamentId Paramter has no value.")));
                }
                var results = _countryRepository.GetCountryBasedOnTournament(tournamentId);

                if (results != null)
                {
                    _logger.LogInformation("Get countries for sport id : {0} successful.", tournamentId);
                    return(Ok(results));
                }
                else
                {
                    _logger.LogInformation("Get countries for sport id : {0} has no items", tournamentId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No items found.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogInformation("Get countries for sport id : {0}.  Error - {1}", tournamentId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed to retrieve items.")));
            }
        }
        public IActionResult Get(int?tournamentId)
        {
            try
            {
                if (!tournamentId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No paramter provided for Market Odds")));
                }

                var result = _oddsRepository.GetMarketOdds(tournamentId);
                if (result.Any())
                {
                    _logger.LogInformation("Get odds for markets for tournament Id : {0} successful", tournamentId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("Get odds for markets for tournament Id : {0} has no items.", tournamentId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Market odds contains no items.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogInformation("Get odds for markets for tournament Id : {0}. Error - {1}", tournamentId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Markets odds has failed")));
            }
        }
Example #4
0
        public IActionResult Put([FromBody] Event @event)
        {
            try
            {
                if (@event.Equals(null))
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("The was no data present.")));
                }
                var result = _eventRepository.Update(@event);

                if (result)
                {
                    _logger.LogInformation("Event ID : {0} successfully updated.", @event.EventId);
                    return(StatusCode(200, StatusCodes.ReturnStatusObject($"{@event.EventId} was Successfully Updated.")));
                }
                else
                {
                    _logger.LogError("Event ID : {0} was not updated.", @event.EventId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject($"Update was unsuccessful.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("The Event update has failed. Error - {0}", e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("The update has failed.")));
            }
        }
Example #5
0
        public IActionResult Get(int?tournamentId)
        {
            try
            {
                if (!tournamentId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Retriving events failed.")));
                }

                var result = _eventRepository.GetAllEventsForTournament(tournamentId);
                if (result.Any())
                {
                    _logger.LogInformation("Get events for tournament ID : {0} successful", tournamentId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("Get events for tournament ID : {0} has no items", tournamentId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Retriving events failed.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogInformation("Get events for tournament ID : {0} has failed", tournamentId);
                return(StatusCode(400, StatusCodes.ReturnStatusObject($"Retriving events failed. Error : {e.Message}")));
            }
        }
 public IActionResult AddMarketBetTypes([FromBody] MarketBetType marketBetType)
 {
     try
     {
         if (marketBetType == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _marketRepository.AddMarketBetTypes(marketBetType);
         if (result)
         {
             _logger.LogInformation("Market Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Market Bet Type Mapping Has Failed to Add. Market - {0}", marketBetType);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Market  Bet Type Mapping failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error Market failed to add . Error - {0} , Data - {1}", e.Message, marketBetType);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Market  Bet Type Mapping Failed to Add.")));
     }
 }
Example #7
0
        public IActionResult Find(int?countryId)
        {
            try
            {
                if (!countryId.HasValue)
                {
                    return(BadRequest("Invalid Input."));
                }
                var result = _countryRepository.Find(countryId);

                if (result != null)
                {
                    _logger.LogInformation($"ID : {countryId} has been successfully found.");
                    return(Ok(result));
                }
                else
                {
                    _logger.LogError("Country ID : {0} was not found.", countryId);
                    return(StatusCode(404, StatusCodes.ReturnStatusObject("Country Not Found.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to located Country. Error - {0}", e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Something went wrong.")));
            }
        }
        public IActionResult GetTournament(int?tournamentId)
        {
            try
            {
                if (!tournamentId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No parameters provided.")));
                }
                var result = _tournamentRepository.GetTournament(tournamentId);

                if (result != null)
                {
                    _logger.LogInformation("Get tournaments for tournamentId {0} successful.", tournamentId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("No items for tournaments  for tournamentId {0}.", tournamentId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No items found")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to get items for tournaments  for tournamentId {0}. Error - {1}", tournamentId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed to recivece items.")));
            }
        }
Example #9
0
 public IActionResult Post([FromBody] Country country)
 {
     try
     {
         if (country == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _countryRepository.Add(country);
         if (result)
         {
             _logger.LogInformation("Country Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Country has Failed to Add. Country - {0}", country);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Country failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error country failed to add . Error - {0} , Data - {1}", e.Message, country);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Country Failed to Add.")));
     }
 }
Example #10
0
        public IActionResult Put([FromBody] Country country)
        {
            try
            {
                if (country.Equals(null))
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("The was no data present.")));
                }
                var result = _countryRepository.Update(country);

                if (result)
                {
                    _logger.LogInformation("Country ID : {0} successfully updated.", country.CountryId);
                    return(StatusCode(200, StatusCodes.ReturnStatusObject($"{country.CountryName} was Successfully Updated.")));
                }
                else
                {
                    _logger.LogError("Country ID : {0} was not updated.", country.CountryId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject($"Update was unsuccessful.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("The Country update has failed. Error - {0}", e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("The update has failed.")));
            }
        }
        public IActionResult GetBetTypes(int?tournamentId)
        {
            try
            {
                if (!tournamentId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Retriving bet types has failed.")));
                }
                var result = _betTypeRepository.GetBetTypesForTournament(tournamentId);

                if (result.Any())
                {
                    _logger.LogInformation("Bet types for tournament Id {0} has been successfully executed.", tournamentId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("Bet types for tournament Id {0} has failed.", tournamentId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Retriving bet types has failed.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogInformation("Bet types for tournament Id {0} has failed. Error : {1}", tournamentId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Retriving bet types has failed.")));
            }
            //_logger.LogInformation("Bet types for tournament Id {0} accessed.",tournamentId);
            //return _betTypeRepository.GetBetTypesForTournament(tournamentId);
        }
Example #12
0
        public IActionResult GetMarkets(int?betTypeId)
        {
            try
            {
                if (!betTypeId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Getting markets failed. No parameter provided.")));
                }

                var result = _marketRepository.GetMarketsForBetType(betTypeId);

                if (result.Any())
                {
                    _logger.LogInformation("Get all markets for bet type Id :{0} successful", betTypeId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("Get all markets for bet type Id :{0} has no items.", betTypeId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No markets found.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Get all markets for bet type Id :{0} has failed. : Error - {1}", betTypeId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Getting markets failed")));
            }
        }
Example #13
0
        public IActionResult Delete(int?countryId)
        {
            try
            {
                if (!countryId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No parameter provided.")));
                }
                var result = _countryRepository.Delete(countryId);

                if (result)
                {
                    _logger.LogInformation($"ID : {countryId} has been successfully deleted.");
                    return(StatusCode(200, StatusCodes.ReturnStatusObject($"ID : {countryId} has been successfully deleted.")));
                }
                else
                {
                    _logger.LogError("Country ID : {0} was not deleted.", countryId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject($"Delete was unsuccessful.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("The Country delete has failed. Error - {0}", e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("The delete has failed.")));
            }
        }
Example #14
0
 public IActionResult AddOdds([FromBody] Odds odds)
 {
     try
     {
         if (odds == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _eventRepository.AddOdds(odds);
         if (result)
         {
             _logger.LogInformation("Odds Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Odds has Failed to Add. Event - {0}", odds);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Odds failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error Odds failed to add . Error - {0} , Data - {1}", e.Message, odds);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Odds Failed to Add." + e.Message)));
     }
 }
        public IActionResult Get(int?sportId, int?countryId)
        {
            try
            {
                if (!sportId.HasValue && !countryId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No parameters provided.")));
                }
                var result = _tournamentRepository.GetAllTournamentsForSportBasedOnCountry(sportId, countryId);

                if (result.Any())
                {
                    _logger.LogInformation("Get tournaments for sport id : {0} and countryId : {1} successful.", sportId, countryId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("No items for tournaments for sport id : {0} and countryId : {1}.", sportId, countryId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No items found")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to get items for tournaments for sport id : {0} and countryId : {1}. Error - {2}", sportId, countryId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed to recivece items.")));
            }
        }
 public IActionResult AddSportTournamentCountry([FromBody] SportTournament sportTournament)
 {
     try
     {
         if (sportTournament == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _tournamentRepository.AddSportTournamentCountry(sportTournament);
         if (result)
         {
             _logger.LogInformation("Tournament Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Tournament has Failed to Add. Tournament - {0}", sportTournament);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Tournament mapping failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error Tournament failed to add . Error - {0} , Data - {1}", e.Message, sportTournament);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Tournament mapping Failed to Add.")));
     }
 }
Example #17
0
        public IActionResult Put([FromBody] BetType betType)
        {
            try
            {
                if (betType.Equals(null))
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("The was no data present.")));
                }
                var result = _betTypeRepository.Update(betType);

                if (result)
                {
                    _logger.LogInformation("Bet Type ID : {0} successfully updated.", betType.BetTypeId);
                    return(StatusCode(200, StatusCodes.ReturnStatusObject($"{betType.BetTypeName} was Successfully Updated.")));
                }
                else
                {
                    _logger.LogError("Bet Type : {0} was not updated.", betType.BetTypeId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject($"Update was unsuccessful.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("The Bet Type update has failed. Error - {0}", e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("The update has failed.")));
            }
        }
Example #18
0
 public IActionResult Post([FromBody] BetType betType)
 {
     try
     {
         if (betType == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _betTypeRepository.Add(betType);
         if (result)
         {
             _logger.LogInformation("Bet Type Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Bet Type has Failed to Add. Bet Type - {0}", betType);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Bet Type failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error Bet Type failed to add . Error - {0} , Data - {1}", e.Message, betType);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Bet Type Failed to Add.")));
     }
 }
        public IActionResult Get(int?sportId)  //https://localhost:44330/api/sportcountry?sportId=5
        {
            try
            {
                if (!sportId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("SportId Paramter has no value.")));
                }
                var results = _countryRepository.GetCountryForSport(sportId);

                if (results.Any())
                {
                    _logger.LogInformation("Get countries for sport id : {0} successful.", sportId);
                    return(Ok(results));
                }
                else
                {
                    _logger.LogInformation("Get countries for sport id : {0} has no items", sportId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No items found.")));
                }
            }
            catch (Exception e)
            {
                _logger.LogInformation("Get countries for sport id : {0}.  Error - {1}", sportId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed to retrieve items.")));
            }
        }
Example #20
0
        public IActionResult Post([FromBody] SportTree sportTree)
        {
            try
            {
                var result = _sportTree.Add(sportTree); // returns a boolean based on the number of rows affected

                if (result)                             // if the post was successfully added to the db it will return true
                {
                    return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added")));
                }
                else // if the post was unsuccesful it will return false
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Insert Failed.")));
                }
            }
            catch (Exception eo)
            {
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Insert Failed.")));
            }
        }
 public IActionResult Get()
 {
     try
     {
         var result = _sportTree.GetAll();
         if (result.Any())
         {
             _logger.LogInformation("Successfully retrieved.");
             return(Ok(result));
         }
         else
         {
             _logger.LogInformation("No items found.");
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items available.")));
         }
     }
     catch
     {
         _logger.LogInformation("Failed to find items.");
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed to retrive items.")));
     }
 }
Example #22
0
 public IActionResult Get()
 {
     try
     {
         var result = _countryRepository.GetAll();
         if (result.Any())
         {
             _logger.LogInformation("Successfully recieved Country Data.");
             return(Ok(result));
         }
         else
         {
             _logger.LogError("No country data. Data - {0}", result);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No country data.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error recieving data. Error - {0}. Data - {1}", e.Message);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error recieving Country data.")));
     }
 }
 public IActionResult GetMarketBetTypes()
 {
     try
     {
         var result = _marketRepository.GetMarketBetTypes();
         if (result.Any())
         {
             _logger.LogInformation("Successfully recieved Market Data.");
             return(Ok(result));
         }
         else
         {
             _logger.LogError("No Market data. Data - {0}", result);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No Market data.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error recieving data. Error - {0}.", e.Message);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error recieving Market data." + e.Message)));
     }
 }
Example #24
0
        public IActionResult AddSportCountryMapping([FromBody] SportCountry sportCountry)
        {
            try
            {
                if (sportCountry.Equals(null))
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No input provided.")));
                }
                var result = _sportTree.AddSportCountryMapping(sportCountry);

                if (result)
                {
                    return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
                }
                else
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Insert has Failed.")));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Insert has Failed. " + e.Message)));
            }
        }
Example #25
0
        public IActionResult DeleteSportCountry(int?sportCountry)
        {
            try
            {
                if (!sportCountry.HasValue)
                {
                    return(BadRequest("Oops something went wrong."));     // if there was no value entered of sportId it will return a bad request.
                }
                var result = _sportTree.DeteleSportCountry(sportCountry); //returns a bool based on a row being effected.

                if (result)
                {
                    return(StatusCode(200, StatusCodes.ReturnStatusObject("Delete successful")));
                }
                else
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Delete Failed.")));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(400, StatusCodes.ReturnStatusObject("The item could not be Deleted. {0}")));
            }
        }
Example #26
0
        public IActionResult Put([FromBody] SportTree sportTree)
        {
            try
            {
                if (sportTree.Equals(null))
                {
                    return(BadRequest("Oops something went wrong.")); // if there was no value entered of sportId it will return a bad request.
                }
                var result = _sportTree.Update(sportTree);            // searches the table using the given idea and if the item is found and updated it will return true

                if (result)
                {
                    return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Updated")));
                }
                else
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("Update Failed.")));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Update Failed.")));
            }
        }
Example #27
0
 public IActionResult Post([FromBody] BetSlipViewModel betSlip)
 {
     //var x =_betSlip.Add(betSlip);
     //return StatusCode(200, StatusCodes.ReturnStatusObject("successful"));
     try
     {
         var result = _betSlip.Add(betSlip);
         if (result)
         {
             _logger.LogInformation("Bet Slip successfully created.");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Bet Successfully Placed.")));
         }
         else
         {
             _logger.LogError("Bet slip was not created.");
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Unsuccessful.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Creating bet slip has failed. Error - {0}", e.Message);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed.")));
     }
 }