Exemplo n.º 1
0
        public void testContextSkill()
        {
            string[] insertNames = { "Volunteer.xlsx", "Group.xlsx", "GroupVol.xlsx", "VolAddress.xlsx",
                                     "VolAddr.xlsx"};
            string[] removeNames = { "Volunteer.xlsx", "Group.xlsx", "GroupVol.xlsx", "VolAddress.xlsx",
                                "VolAddr.xlsx", "Skill.xlsx", "VolSkill.xlsx", "VolState.xlsx",
                                "VolEmail.xlsx", "VolPhone.xlsx"};
            cExcel.RemoveAllData();
            cExcel.InsertData(insertNames);

            string directory = cExcel.GetHelperFilesDir();
            string hdir = cExcel.GetHelperFilesDir();
            sp_Skill_BLL skillBLL = new sp_Skill_BLL();
            string query = "SELECT * FROM [Sheet1$]";
            DataTable dt = cExcel.QueryExcelFile(hdir + "Skill.xlsx", query);
            foreach (DataRow row in dt.Rows)
            {
                sp_Skill_DM dmskill = new sp_Skill_DM();

                dmskill.ActiveFlg = Convert.ToInt32(row["ActiveFlg"]);
                dmskill.MstrSkillID = row["MstrSkillID"].ToString() == "" ? new Nullable<Guid>() : (Guid?)(new Guid(row["MstrSkillID"].ToString()));
                dmskill.SkillID = new Guid(row["SkillID"].ToString());
                dmskill.SkillName = row["SkillName"].ToString();
                System.Console.WriteLine(row["MstrSkillID"]);
                //Push data into the database and then check to see if the data
                //we get out the other end is the same.
                skillBLL.InsertSkillContext(ref dmskill);
                sp_Skill_DM returned_Skill = skillBLL.ListSingleSkill(dmskill.SkillID);
                Assert.AreEqual(returned_Skill, dmskill);
            }
            cExcel.RemoveData(removeNames);
        }
Exemplo n.º 2
0
        protected void rBTNProcess_Click(object sender, EventArgs e)
        {
            MembershipUser currentUser = Membership.GetUser();
            Guid? VolID = (Guid)currentUser.ProviderUserKey;

            //Delete all associated VolSkills for the given volid
            VolSkillBLL.DeleteVolSkillALL(VolID);

            AutoCompleteBoxEntryCollection entries = this.rACSkills.Entries;

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].Value == string.Empty)
                {
                    // Skill doesn't exist, insert new Skill, return SkillID through domain model
                    sp_Skill_DM SkillsDM = new sp_Skill_DM();
                    SkillsDM.SkillName = entries[i].Text.ToString();
                    SkillsDM.MstrSkillID = null;
                    SkillsBLL.InsertSkillContext(ref SkillsDM);

                    // write the existing skill to VolSkill
                    VolSkillBLL.InsertVolSkill(VolID, SkillsDM.SkillID);
                }
                else
                {
                    //Skill does exist, use existing SkillID to insert into VolSkill
                    Guid? SkillID = new Guid(entries[i].Value);

                    // write the existing skill to VolSkill
                    VolSkillBLL.InsertVolSkill(VolID, SkillID);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// DeleteSkillContext - Will do a soft delete (make inactive) by SkillID
        /// </summary>
        /// <param name="_cSkill"></param>
        public void DeleteSkillContext(sp_Skill_DM _cSkill)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var SkillToRemove = (from n in context.tblSkills where n.SkillID == _cSkill.SkillID select n).FirstOrDefault();
                context.tblSkills.Remove(SkillToRemove);
                context.SaveChanges();

            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// InsertSkillContext - Will insert a record into Skill table via SProc
 /// </summary>
 /// <param name="_cSkill"></param>
 public void InsertSkillContext(ref sp_Skill_DM _cSkill)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var cSkill = new tblSkill
         {
             SkillName = _cSkill.SkillName,
             MstrSkillID = _cSkill.MstrSkillID
         };
         context.tblSkills.Add(cSkill);
         context.SaveChanges();
         _cSkill.SkillID = cSkill.SkillID;
     }
 }
Exemplo n.º 5
0
 public void UpdateSampleAddressContext(sp_Skill_DM _cSkill)
 {
     DAL.UpdateSampleAddressContext(_cSkill);
 }
Exemplo n.º 6
0
 public void InsertSkillContext(sp_Skill_DM _cSkill)
 {
     DAL.InsertSkillContext(_cSkill);
 }
Exemplo n.º 7
0
 public void DeleteSkillContext(sp_Skill_DM _cSkill)
 {
     DAL.DeleteSkillContext(_cSkill);
 }
Exemplo n.º 8
0
        public void testDeleteSkill()
        {
            string[] tablesToFill = { "Volunteer.xlsx", "Group.xlsx", "GroupVol.xlsx", "VolAddress.xlsx",
                                "VolAddr.xlsx", "Skill.xlsx", "VolSkill.xlsx", "VolState.xlsx",
                                "VolEmail.xlsx", "VolPhone.xlsx"};
            cExcel.RemoveAllData();
            cExcel.InsertData(tablesToFill);

            string directory = cExcel.GetHelperFilesDir();
            string hdir = cExcel.GetHelperFilesDir();
            sp_Skill_BLL skillBLL = new sp_Skill_BLL();
            string query = "SELECT * FROM [Sheet1$]";
            DataTable dt = cExcel.QueryExcelFile(hdir + "Skill.xlsx", query);
            List<Tuple<Guid, String, int, Guid?>> rowTree = new List<Tuple<Guid, string, int, Guid?>>();

            foreach (DataRow row in dt.Rows)
            {
                var key = new Guid(row["SkillID"].ToString());
                var mstr = row["MstrSkillID"].ToString() == "" ? new Nullable<Guid>() : (Guid?)(new Guid(row["MstrSkillID"].ToString()));
                var activeFlag = Convert.ToInt32(row["ActiveFlg"]);
                var skillname = row["SkillName"].ToString();
                rowTree.Add(Tuple.Create<Guid, string, int, Guid?>(key, skillname, activeFlag, mstr));
            }
            //this function returns the guid of the parent we deleted
            Func<Guid, List<Tuple<Guid, String, int, Guid?>>> deleteReturnParent = (Guid key) =>
            {
                //Check to make sure this key is still contained in the database based
                //on the description of how it should work.
                var toDeleteRow = rowTree.Find((x) => {
                        return x.Item1.Equals(key);
                });
                rowTree.Remove(toDeleteRow);
                //Find all rows that have the key as their mstrskill
                var updateRows = rowTree.FindAll((x) =>
                {
                    return x.Item4.Equals(key);
                });
                //Remove them
                rowTree.RemoveAll((x) =>
                {
                    return x.Item4.Equals(key);
                });
                var returnList = new List<Tuple<Guid, String, int, Guid?>>();
                foreach (var row in updateRows){
                    //Update them so that their master skill ids point at the master skill of the deleted node
                    var guidTpl = Tuple.Create<Guid, String, int, Guid?>(row.Item1, row.Item2, row.Item3, toDeleteRow.Item4);
                    rowTree.Add(guidTpl);
                    returnList.Add(guidTpl);
                }
                return returnList;
            };

            foreach (DataRow row in dt.Rows)
            {
                sp_Skill_DM dmskill = new sp_Skill_DM();
                dmskill.ActiveFlg = Convert.ToInt32(row["ActiveFlg"]);
                dmskill.MstrSkillID = row["MstrSkillID"].ToString() == "" ? new Nullable<Guid>() : (Guid?)(new Guid(row["MstrSkillID"].ToString()));
                dmskill.SkillID = new Guid(row["SkillID"].ToString());
                dmskill.SkillName = row["SkillName"].ToString();

                //Delete a skill
                int before = cExcel.getNumRecordsFromDB("Vol.tblVolSkill");
                skillBLL.DeleteSkillContext(dmskill);
                var updatedList = deleteReturnParent(dmskill.SkillID);
                int after = cExcel.getNumRecordsFromDB("Vol.tblVolSkill");
                //Did the skill actually get deleted.
                Assert.AreEqual(before - 1, after);
                //Did all the values get properly updated
                foreach (var updatedRow in updatedList){
                    sp_Skill_DM updatedSkill = skillBLL.ListSingleSkill(updatedRow.Item1);
                    Assert.AreEqual(updatedSkill.ActiveFlg, updatedRow.Item3);
                    Assert.AreEqual(updatedSkill.MstrSkillID, updatedRow.Item4);
                    Assert.AreEqual(updatedSkill.SkillName, updatedRow.Item2);
                }
            }
            cExcel.RemoveData(tablesToFill);
        }
Exemplo n.º 9
0
        /// <summary>
        /// UpdateSampleAddressContext - Will update a given Skill record by SkillID
        /// </summary>
        /// <param name="_cSkill"></param>
        public void UpdateSampleAddressContext(sp_Skill_DM _cSkill)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var cSkill = context.tblSkills.Find(_cSkill.SkillID);

                if (cSkill != null)
                {
                    cSkill.SkillID = _cSkill.SkillID;
                    cSkill.SkillName = _cSkill.SkillName;
                    cSkill.MstrSkillID = _cSkill.MstrSkillID;
                    context.SaveChanges();
                }
            }
        }