Example #1
0
        public static int Save2(int lotteryId, LotteryGameValue gameToSave)
        {
            int returnValue;
            returnValue = LotteryGameDAL.Save2(lotteryId, gameToSave);

            return returnValue;
        }
Example #2
0
        public static int Save(LotteryGameValue lotteryGameId)
        {
            int returnValue;
            returnValue = LotteryGameDAL.Save(lotteryGameId);

            return returnValue;
        }
Example #3
0
        private static int SaveGame(LotteryGameDetail detailsToSave)
        {
            LotteryGameValue tempGame = new LotteryGameValue();
            tempGame.LotteryGameId = detailsToSave.LotteryGameId;

            if (detailsToSave.GameName != null)
                tempGame.GameName = detailsToSave.GameName;

            if (detailsToSave.GameNameAbbrev != null)
                tempGame.GameNameAbbrev = detailsToSave.GameNameAbbrev;

            return LotteryGameManager.Save(tempGame);
        }
Example #4
0
        public static int SaveGame(int lotteryId, LotteryGameValue gameToSave)
        {
            //notes:    instantiate BrokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (lotteryId <= 0)
                saveBrokenRules.Add("Lottery", "Invalid Lottery Game Id");

            if (gameToSave == null)
                saveBrokenRules.Add("Game Name", "Invalid GameName objects.");

            else
            {
                if (string.IsNullOrEmpty(gameToSave.GameName))
                    saveBrokenRules.Add("Game Name", "Game Name is required");
            }

            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
                return LotteryGameDAL.Save2(lotteryId, gameToSave);
        }
        private LotteryGameValue HydrateLotteryGame(LotteryGameDTO lotteryGameDTO)
        {
            LotteryGameValue tempItem = new LotteryGameValue();

            if(lotteryGameDTO !=null)
            {
                tempItem.LotteryGameId = lotteryGameDTO.LotteryGameId;

                if (!string.IsNullOrEmpty(lotteryGameDTO.GameName))
                    tempItem.GameName = lotteryGameDTO.GameName;
            }

            return tempItem;
        }
        private LotteryGameDTO HydrateLotteryGameDTO(LotteryGameValue lotteryGame)
        {
            LotteryGameDTO tempItem = new LotteryGameDTO();

            if (lotteryGame !=null)
            {
                tempItem.LotteryGameId = lotteryGame.LotteryGameId;

                if (!string.IsNullOrEmpty(lotteryGame.GameName))
                    tempItem.GameName = lotteryGame.GameName;
            }

            return tempItem;
        }
Example #7
0
        public static int Save(LotteryGameValue gameToSave)
        {
            int result = 0;
            ExecuteTypeEnum queryId = ExecuteTypeEnum.InsertItem;

            // notes:       check for valid LotteryGameId - if exists then UPDATE , else INSERT
            if (gameToSave.LotteryGameId > 0)
                queryId = ExecuteTypeEnum.UpdateItem;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_ExecuteGame", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", queryId);

                    if (gameToSave.GameName != null)
                        myCommand.Parameters.AddWithValue("@GameName", gameToSave.GameName);
                    if (gameToSave.GameName != null)
                        myCommand.Parameters.AddWithValue("@GameAbbreviation", gameToSave.GameNameAbbrev);

                    //notes:    add return output parameter to command object
                    myCommand.Parameters.Add(HelperDAL.GetReturnParameterInt("ReturnValue"));

                    myConnection.Open();
                    myCommand.ExecuteNonQuery();

                    //notes:    get return value from stored procedure and return Id
                    result = (int)myCommand.Parameters["@ReturnValue"].Value;
                }
                myConnection.Close();
            }
            return result;
        }
Example #8
0
        private static LotteryGameValue FillDataRecord(IDataRecord myDataRecord)
        {
            LotteryGameValue myObject = new LotteryGameValue();

            myObject.LotteryGameId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("LotteryGameId"));

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("GameName")))
                myObject.GameName = myDataRecord.GetString(myDataRecord.GetOrdinal("GameName"));

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("GameAbbreviation")))
                myObject.GameNameAbbrev = myDataRecord.GetString(myDataRecord.GetOrdinal("GameAbbreviation"));

            return myObject;
        }
Example #9
0
        //    private static void PowerBall()
        //    {
        //        string firstGame = "PowerBall";
        //        DateTime dt = DateTime.Parse("18 Dec 2013");
        //        int firstNumber= 7;
        //        int secondNumber= 24;
        //        int thirdNumber= 37;
        //        int fourthNumber= 39;
        //        int fifthNumber = 40;
        //        int powerBall = 1;
        //        string estimatedJackpot = "$60,000,000";
        //        string estimatedCashoption = "$33,300,000";
        //        DateTime jackpotDrawingdate = DateTime.Parse("21 Dec 2013");
        //        System.Console.WriteLine(firstGame);
        //        System.Console.WriteLine(dt);
        //        System.Console.WriteLine(firstNumber);
        //        System.Console.WriteLine(secondNumber);
        //        System.Console.WriteLine(thirdNumber);
        //        System.Console.WriteLine(fourthNumber);
        //        System.Console.WriteLine(fifthNumber);
        //        System.Console.WriteLine(powerBall);
        //        System.Console.WriteLine(estimatedJackpot);
        //        System.Console.WriteLine(estimatedCashoption);
        //        System.Console.WriteLine(jackpotDrawingdate);
        //    }
        //    private static void MegaMillions()
        //{
        //    string secondGame= "Mega Millions";
        //    DateTime dt = DateTime.Parse("17 Dec 2013");
        //    int firstNumber = 8;
        //    int secondNumber = 14;
        //    int thirdNumber = 17;
        //    int fourthNumber = 20;
        //    int fifthNumber = 39;
        //    int megaBall = 7;
        //    string estimatedJackpot = "$15,000,000";
        //    string estimatedCashoption = "$8,000,000";
        //    DateTime jackpotDrawingdate = DateTime.Parse("20 Dec 2013");
        //    System.Console.WriteLine(secondGame);
        //    System.Console.WriteLine(dt);
        //    System.Console.WriteLine(firstNumber);
        //    System.Console.WriteLine(secondNumber);
        //    System.Console.WriteLine(thirdNumber);
        //    System.Console.WriteLine(fourthNumber);
        //    System.Console.WriteLine(fifthNumber);
        //    System.Console.WriteLine(megaBall);
        //    System.Console.WriteLine(estimatedJackpot);
        //    System.Console.WriteLine(estimatedCashoption);
        //    System.Console.WriteLine(jackpotDrawingdate);
        //}
        //private static void HotLotto()
        //{
        //    string thirdGame = "Mega Millions";
        //    DateTime dt = DateTime.Parse("18 Dec 2013");
        //    int firstNumber = 8;
        //    int secondNumber = 27;
        //    int thirdNumber = 32;
        //    int fourthNumber = 40;
        //    int fifthNumber = 46;
        //    int hotBall = 4;
        //    string estimatedJackpot = "$1,950,000";
        //    DateTime jackpotDrawingdate = DateTime.Parse("21 Dec 2013");
        //    System.Console.WriteLine(thirdGame);
        //    System.Console.WriteLine(dt);
        //    System.Console.WriteLine(firstNumber);
        //    System.Console.WriteLine(secondNumber);
        //    System.Console.WriteLine(thirdNumber);
        //    System.Console.WriteLine(fourthNumber);
        //    System.Console.WriteLine(fifthNumber);
        //    System.Console.WriteLine(hotBall);
        //    System.Console.WriteLine(estimatedJackpot);
        //    System.Console.WriteLine(jackpotDrawingdate);
        //}
        //private static void Gopher5()
        //{
        //    string fourthGame = "Gopher 5";
        //    DateTime dt = DateTime.Parse("18 Dec 2013");
        //    int firstNumber = 2;
        //    int secondNumber = 9;
        //    int thirdNumber = 12;
        //    int fourthNumber = 36;
        //    int fifthNumber = 39;
        //    string estimatedJackpot = "$130,000";
        //   // DateTime jackpotDrawingDate = DateTime.Parse("20 Dec 2013");
        //    DateTime jackpotDrawingDate = new DateTime(2013, 12, 20);
        //    System.Console.WriteLine(fourthGame);
        //    System.Console.WriteLine(dt);
        //    System.Console.WriteLine(firstNumber);
        //    System.Console.WriteLine(secondNumber);
        //    System.Console.WriteLine(thirdNumber);
        //    System.Console.WriteLine(fourthNumber);
        //    System.Console.WriteLine(fifthNumber);
        //    System.Console.WriteLine(estimatedJackpot);
        //    System.Console.WriteLine(jackpotDrawingDate);
        //}
        //private static void ListArray()
        //{
        //    List<string> GameName = new List<string>();
        //    string[] WinningNumber = new string[4];
        //    string[] EstimatedJackpot = new string[4];
        //    GameName.Add("PowerBall");
        //    WinningNumber[0] = "7  24 37 39 40 1";
        //    EstimatedJackpot[0] = "$60,000,000";
        //    GameName.Add("Mega Millions");
        //    WinningNumber[1] = "8 14 17 20 39 7";
        //    EstimatedJackpot[1] = "$15,000,000";
        //    GameName.Add("Hot Lotto");
        //    WinningNumber[2] = "8 27 32 40 46 4";
        //    EstimatedJackpot[2] = "$1,950,000";
        //    GameName.Add("Gopher 5");
        //    WinningNumber[3] = "2 9 12 36 39";
        //    EstimatedJackpot[3] = "$130,000";
        //    int i = 0;
        //    foreach (string stringValue in GameName)
        //    {
        //        System.Console.WriteLine(stringValue);
        //        System.Console.WriteLine(WinningNumber[i]);
        //        System.Console.WriteLine(EstimatedJackpot[i]);
        //        i++;
        //    }
        //}
        //private static void Menu()
        //{
        //    System.Console.WriteLine("Please select from the following options to view lottery game info:");
        //    System.Console.WriteLine("----------------------------------------------------------");
        //    System.Console.WriteLine("1 : Powerball");
        //    System.Console.WriteLine("2 : Mega Millions");
        //    System.Console.WriteLine("3 : Hot Lotto");
        //    System.Console.WriteLine("4 : Gopher 5");
        //    System.Console.WriteLine("----------------------------------------------------------");
        //    string GameName1, GameName2, GameName3, GameName4;
        //    string WinningNumber1, WinningNumber2, WinningNumber3, WinningNumber4;
        //    string EstimatedJackpot1, EstimatedJackpot2, EstimatedJackpot3, EstimatedJackpot4;
        //    GameName1 = "PowerBall";
        //    WinningNumber1 = "7  24 37 39 40 1";
        //    EstimatedJackpot1 = "$60,000,000";
        //    GameName2 = "Mega Millions";
        //    WinningNumber2 = "8 14 17 20 39 7";
        //    EstimatedJackpot2 = "$15,000,000";
        //    GameName3 = "Hot Lotto";
        //    WinningNumber3 = "8 27 32 40 46 4";
        //    EstimatedJackpot3 = "$1,950,000";
        //    GameName4 = "Gopher 5";
        //    WinningNumber4 = "2 9 12 36 39";
        //    EstimatedJackpot4 = "$130,000";
        //    string Games = System.Console.ReadLine();
        //    try
        //    {
        //        switch (Games)
        //        {
        //            case "1":
        //                System.Console.WriteLine(GameName1);
        //                System.Console.WriteLine(WinningNumber1);
        //                System.Console.WriteLine(EstimatedJackpot1);
        //                break;
        //            case "2":
        //                System.Console.WriteLine(GameName2);
        //                System.Console.WriteLine(WinningNumber2);
        //                System.Console.WriteLine(EstimatedJackpot2);
        //                break;
        //            case "3":
        //                System.Console.WriteLine(GameName3);
        //                System.Console.WriteLine(WinningNumber3);
        //                System.Console.WriteLine(EstimatedJackpot3);
        //                break;
        //            case "4":
        //                System.Console.WriteLine(GameName4);
        //                System.Console.WriteLine(WinningNumber4);
        //                System.Console.WriteLine(EstimatedJackpot4);
        //                break;
        //            default:
        //                System.Console.WriteLine("Please select a valid number!");
        //                break;
        //        }
        //    }
        //    catch (FormatException ex)
        //    {
        //        System.Console.WriteLine("Exception: " + ex.Message);
        //    }
        //    finally
        //    {
        //        System.Console.WriteLine("Program has completed regardless of Exceptions.");
        //    }
        //}
        private static void Code()
        {
            int game = 0;
            int drawing = 0;
            int number = 0;

            game = Convert.ToInt32(Console.ReadLine());
            drawing = Convert.ToInt32(Console.ReadLine());
            number = Convert.ToInt32(Console.ReadLine());

            LotteryGameValue pb = new LotteryGameValue();
            pb = LotteryGameDAL.GetItem(game);

            LotteryDrawing mb = new LotteryDrawing();
            mb = LotteryDrawingDAL.GetItem(drawing);

            DrawingNumberCollection numc = new DrawingNumberCollection();
            numc = DrawingNumberDAL.GetCollection(number);

            int id = 0;
            int page = 0;
            int row = 0;

            id = Convert.ToInt32(Console.ReadLine());
            page = Convert.ToInt32(Console.ReadLine());
            row = Convert.ToInt32(Console.ReadLine());

            LotteryDrawingCollection drawc = new LotteryDrawingCollection();
            drawc = LotteryDrawingDAL.GetCollection(id, page, row);

            foreach (LotteryDrawing item in drawc)
            {
                System.Console.WriteLine(item.GetDrawing());
            }
            System.Console.ReadKey();
            //System.Console.WriteLine("");
            //foreach (DrawingNumber item in number)
            //{
            //    System.Console.WriteLine(item.GetItem());
            //}

            //System.Console.WriteLine(pb.GetGame());
            //System.Console.ReadKey();
            //System.Console.WriteLine("");

            //LotteryDrawing drawing = new LotteryDrawing();
            //drawing = LotteryDrawingDAL.GetItem(12);

            // System.Console.WriteLine(drawing.GetDrawing());

            //DrawingNumberCollection number = new DrawingNumberCollection();
            //number = DrawingNumberDAL.GetCollection(5);

            //foreach (DrawingNumber item in number)
            //{
            //    System.Console.WriteLine(item.GetItem());
            //}

            //LotteryGameCollection drawing = new LotteryGameCollection();
            //drawing = LotteryGameDAL.GetCollection();

            //foreach (LotteryGameValue item in drawing)
            //{
            //    System.Console.WriteLine(item.GetGame());
            //}

            //LotteryDrawingCollection drawing = new LotteryDrawingCollection();
            //drawing = LotteryDrawingDAL.GetCollection(4,1,5);

            //foreach (LotteryDrawing item in drawing)
            //{
            //    System.Console.WriteLine(item.GetDrawing());
            //}
        }