Example #1
0
 public void TestGetCommandReturnsTrueWithNonExistingSkillAndAddsItToTheDatabase()
 {
     string skill = "python";
     InsertSkill ins = new InsertSkill();
     bool insert = ins.GetCommand(skill);
     Assert.IsTrue(insert);
 }
Example #2
0
 public void TestFormatSkillReturnsCorrectSkillString()
 {
     string skill = "dot net";
     InsertSkill ins = new InsertSkill();
     string newSkill = ins.FormatSkill(skill);
     Assert.AreEqual("Dot Net", newSkill);
 }
Example #3
0
 public void TestGetCommandReturnsTrueWithExistingSkill()
 {
     string skill = "SQL";
     InsertSkill ins = new InsertSkill();
     string newSkill = ins.FormatSkill(skill);
     Assert.IsTrue(ins.GetCommand(skill));
 }
Example #4
0
        public bool GetCommand(string skill, int userID)
        {
            ConnectionString cnString = new ConnectionString();
            IDbConnection cn = new OleDbConnection(cnString.GetConnString());

            try
            {
                cn.Open();
                IDbTransaction tran = cn.BeginTransaction();

                // Add userskill
                IDbCommand cmd = new OleDbCommand("sp_del_userSkill", (OleDbConnection)cn);
                cmd.Transaction = tran;
                cmd.CommandType = CommandType.StoredProcedure;

                Console.WriteLine(userID);
                InsertSkill ins = new InsertSkill();
                string formattedSkill = ins.FormatSkill(skill);
                GetSkillId id = new GetSkillId();
                int skillid = int.Parse(id.Read(formattedSkill));
                cmd.Parameters.Add(new OleDbParameter("@userID", int.Parse(userID.ToString())));
                cmd.Parameters.Add(new OleDbParameter("@skillID", int.Parse(skillid.ToString())));
                int affectedRows = cmd.ExecuteNonQuery();

                if (affectedRows > 0)
                {
                    tran.Commit();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch(Exception e)
            {

                Console.WriteLine(e.Message);
                return false;
            }
        }
Example #5
0
        public bool GetCommand(string skill, int userID)
        {
            ConnectionString cnString = new ConnectionString();
            IDbConnection    cn       = new OleDbConnection(cnString.GetConnString());

            try
            {
                cn.Open();
                IDbTransaction tran = cn.BeginTransaction();

                // Add userskill
                IDbCommand cmd = new OleDbCommand("sp_del_userSkill", (OleDbConnection)cn);
                cmd.Transaction = tran;
                cmd.CommandType = CommandType.StoredProcedure;

                Console.WriteLine(userID);
                InsertSkill ins            = new InsertSkill();
                string      formattedSkill = ins.FormatSkill(skill);
                GetSkillId  id             = new GetSkillId();
                int         skillid        = int.Parse(id.Read(formattedSkill));
                cmd.Parameters.Add(new OleDbParameter("@userID", int.Parse(userID.ToString())));
                cmd.Parameters.Add(new OleDbParameter("@skillID", int.Parse(skillid.ToString())));
                int affectedRows = cmd.ExecuteNonQuery();

                if (affectedRows > 0)
                {
                    tran.Commit();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
        }
Example #6
0
 public void TestDetermineIfExistsReturnsTrueWithExistingSkill()
 {
     InsertSkill ins = new InsertSkill();
     Assert.IsTrue(ins.DetermineIfExists("java"));
 }
Example #7
0
 public void TestDetermineIfExistsReturnsFalseWithNonExistingSkill()
 {
     InsertSkill ins = new InsertSkill();
     Assert.IsFalse(ins.DetermineIfExists("prolog"));
 }
Example #8
0
        public string FormatSkill(string skill)
        {
            InsertSkill insSkill = new InsertSkill();

            return(insSkill.FormatSkill(skill));
        }
Example #9
0
        public bool InsertSkill(string skill)
        {
            InsertSkill insSkill = new InsertSkill();

            return(insSkill.GetCommand(skill));
        }
Example #10
0
 public bool InsertSkill(string skill)
 {
     InsertSkill insSkill = new InsertSkill();
     return insSkill.GetCommand(skill);
 }
Example #11
0
 public string FormatSkill(string skill)
 {
     InsertSkill insSkill = new InsertSkill();
     return insSkill.FormatSkill(skill);
 }