Beispiel #1
0
        void Handle(Input.Trend action)
        {
            Franchises.Clear();
            var franchises = Db.SQL <Franchise>("SELECT f FROM SafaArooj.Franchise f WHERE f.Coorporation = ? ORDER BY f.Trend", Data);

            Franchises.Data = franchises;
        }
        public async Task <IActionResult> Edit(string id, [Bind("FranchiseNo,FranchiseName,FranchiseAddress,FranchisePostcode,FranchiseTel,FranchiseFax,FranchiseStartdate,FranchisorNo")] Franchises franchises)
        {
            if (id != franchises.FranchiseNo)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(franchises);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FranchisesExists(franchises.FranchiseNo))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FranchisorNo"] = new SelectList(_context.Franchisors, "FranchisorNo", "FranchisorNo", franchises.FranchisorNo);
            return(View(franchises));
        }
Beispiel #3
0
        public void PullFranchisesTest()
        {
            Franchises test = new Franchises();

            test = dao.PullSpecificFranchise(101);
            Assert.AreEqual(101, test.Franchise_Id);
            Assert.AreEqual("Coder Legacy", test.Franchise_Name);
        }
Beispiel #4
0
        public void FullFranchiseTest()
        {
            dao.PushFranchise(420, "CyberRocker");
            Franchises test = new Franchises();

            test = dao.PullSpecificFranchise(420);
            Assert.AreEqual(true, dao.CheckFranchiseID(420));
            Assert.AreEqual(420, test.Franchise_Id);
            Assert.AreEqual("CyberRocker", test.Franchise_Name);
        }
        public async Task <IActionResult> Create([Bind("FranchiseNo,FranchiseName,FranchiseAddress,FranchisePostcode,FranchiseTel,FranchiseFax,FranchiseStartdate,FranchisorNo")] Franchises franchises)
        {
            if (ModelState.IsValid)
            {
                _context.Add(franchises);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FranchisorNo"] = new SelectList(_context.Franchisors, "FranchisorNo", "FranchisorNo", franchises.FranchisorNo);
            return(View(franchises));
        }
        public void FranchiseAddToSQLTest()
        {
            IList <GameInfo> testList = new List <GameInfo>();

            testList = mediator.GetGames("Halo", false);
            mediator.PushFranchiseIntoSQL(testList);
            Franchises test = new Franchises();

            test = daoFranchises.PullSpecificFranchise(137);
            Assert.AreEqual(137, test.Franchise_Id);
            Assert.AreEqual("Halo", test.Franchise_Name);
        }
 public void PushFranchiseIntoSQL(IList <GameInfo> games)
 {
     //Takes the results from IGDB query and inserts any missing franchises into SQL DB
     foreach (GameInfo x in games)
     {
         if (!franchiseSQLDAO.CheckFranchiseID(x.franchiseID))
         {
             Franchises newFranchise = new Franchises();
             newFranchise = franchisesIGDBDAO.PullSpecificFranchise(x.franchiseID);
             franchiseSQLDAO.PushFranchise(newFranchise.Franchise_Id, newFranchise.Franchise_Name);
         }
     }
 }
        public Franchises PullSpecificFranchise(int franchiseID)
        {
            //Creates IGDB client using our apiKey
            var igdb = IGDB.Client.Create(Environment.GetEnvironmentVariable(apiKey));

            igdb.ApiKey = apiKey;

            //Queries IGDB and pulls url based on franchise ID that we pull from our game search method
            var        franchiseInfo = Task.Run(() => igdb.QueryAsync <Franchise>(IGDB.Client.Endpoints.Franchies, query: $"fields *;where id = {franchiseID};")).Result;
            Franchises newFranchise  = new Franchises
            {
                Franchise_Id   = franchiseID,
                Franchise_Name = franchiseInfo[0].Name
            };

            return(newFranchise);
        }
        public async Task <Tuple <bool, string, MultipleSecreateKeys> > GetUsernameWalletMasterCharges(string DcIDorName)
        {
            Tuple <bool, string, MultipleSecreateKeys> result = null;
            Franchises           franchisesDetails            = new Franchises();
            Wallet               walletDetails           = new Wallet();
            MasterCharges        masterChargesDetails    = new MasterCharges();
            MultipleSecreateKeys lstMultipleSecreateKeys = new MultipleSecreateKeys();

            try
            {
                using (SqlConnection con = new SqlConnection(_dcDb))
                {
                    var parameters = new DynamicParameters();
                    parameters.Add("@DcIDorName", DcIDorName);
                    con.Open();

                    using (var multi = await con.QueryMultipleAsync("dbo.Select_FranchiseIDandName_RegKey", parameters, commandType: CommandType.StoredProcedure))
                    {
                        franchisesDetails    = multi.Read <Franchises>().Single();
                        walletDetails        = multi.Read <Wallet>().Single();
                        masterChargesDetails = multi.Read <MasterCharges>().Single();
                        lstMultipleSecreateKeys.Franchise     = franchisesDetails;
                        lstMultipleSecreateKeys.Wallet        = walletDetails;
                        lstMultipleSecreateKeys.MasterCharges = masterChargesDetails;
                    }
                    con.Close();
                }
                if (lstMultipleSecreateKeys != null)
                {
                    result = Tuple.Create(true, "", lstMultipleSecreateKeys);
                }
                else
                {
                    result = Tuple.Create(false, AppConstants.NO_RECORDS_FOUND, lstMultipleSecreateKeys);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(ex);
                result = Tuple.Create(false, ex.Message, lstMultipleSecreateKeys);
            }
            return(result);
        }
Beispiel #10
0
        public void PushFranchisesTest()
        {
            Franchises test = new Franchises();

            dao.PushFranchise(340, "A series of unfortunate calls");
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                SqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = @"select * from Franchises where franchise_Id = 340";
                cmd.ExecuteNonQuery();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    test.Franchise_Id   = (int)reader["franchise_id"];
                    test.Franchise_Name = (string)reader["franchise_name"];
                }
            }
            Assert.AreEqual(340, test.Franchise_Id);
            Assert.AreEqual("A series of unfortunate calls", test.Franchise_Name);
        }
        public Franchises PullSpecificFranchise(int franchiseID)
        {
            //Pulls specific Franchise based on the id from the DB
            Franchises pulledFranchise = new Franchises();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = @"select franchise_id,franchise_name from Franchises
                where franchise_id = @franchiseId";
                cmd.Parameters.AddWithValue("@franchiseId", franchiseID);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    pulledFranchise.Franchise_Id   = (int)reader["franchise_id"];
                    pulledFranchise.Franchise_Name = (string)reader["franchise_name"];
                }
            }
            return(pulledFranchise);
        }
Beispiel #12
0
        public async Task <Tuple <bool, string, Franchises, Wallet> > GetFranchiseUsernameWalletByIDorName(string DcIDorName)
        {
            Tuple <bool, string, Franchises, Wallet> result = null;
            Franchises franchisesDetails = new Franchises();
            Wallet     walletDetails     = new Wallet();

            try
            {
                using (SqlConnection con = new SqlConnection(_dcDb))
                {
                    var parameters = new DynamicParameters();
                    parameters.Add("@DcIDorName", DcIDorName);
                    con.Open();

                    using (var multi = await con.QueryMultipleAsync("dbo.Select_FranchiseIDandName_Wallet", parameters, commandType: CommandType.StoredProcedure))
                    {
                        franchisesDetails = multi.Read <Franchises>().Single();
                        walletDetails     = multi.Read <Wallet>().Single();
                    }
                    con.Close();
                }
                if (franchisesDetails != null)
                {
                    result = Tuple.Create(true, "", franchisesDetails, walletDetails);
                }
                else
                {
                    result = Tuple.Create(false, AppConstants.NO_RECORDS_FOUND, franchisesDetails, walletDetails);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(ex);
                result = Tuple.Create(false, ex.Message, franchisesDetails, walletDetails);
            }
            return(result);
        }
Beispiel #13
0
 public static void Reset()
 {
     Types.Clear();
     Franchises.Clear();
     Wallpapers.Clear();
 }