Пример #1
0
        public sp_Phone_DM ListPrimaryPhone(sp_Phone_DM cVolPhone)
        {
            List<sp_Phone_DM> list = new List<sp_Phone_DM>();
            try
            {
                using (VolTeerEntities context = new VolTeerEntities())
                {
                    list = (from result in context.sp_Vol_Phone_Select(cVolPhone.VolID, null, true)
                            select new sp_Phone_DM
                            {
                                PhoneID = result.PhoneID,
                                PhoneNbr = result.PhoneNbr,
                                VolID = result.VolID,
                                ActiveFlg = result.ActiveFlg,
                                PrimaryFlg = result.PrimaryFlg
                            }).ToList();
                } // Guaranteed to close the Connection
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return list.FirstOrDefault();
        }
Пример #2
0
        public static void InsertVolPhoneData(TestContext testContext)
        {
            System.Diagnostics.Debug.WriteLine(String.Format("{0}", DateTime.Now));
            cExcel.RemoveAllData();
            cExcel.InsertData(ExcelFilenames);

            sp_Volunteer_BLL volBLL = new sp_Volunteer_BLL();
            generalTestVol = new sp_Volunteer_DM();
            generalTestVol.VolFirstName = "TestFirst";
            generalTestVol.VolMiddleName = "TestMiddle";
            generalTestVol.VolLastName = "TestLast";
            generalTestVol.ActiveFlg = true;
            System.Guid volID = Guid.NewGuid();
            generalTestVol.VolID = volID;
            volBLL.InsertVolunteerContext(ref generalTestVol);

            sp_VolPhone_BLL volPhone_bll = new sp_VolPhone_BLL();
            primaryTestVolPhone = new sp_Phone_DM();
            primaryTestVolPhone.PhoneNbr = "1357924680";
            primaryTestVolPhone.VolID = volID;
            primaryTestVolPhone.ActiveFlg = true;
            primaryTestVolPhone.PrimaryFlg = true;
            volPhone_bll.InsertPhoneContext(primaryTestVolPhone);

            secondaryTestVolPhone = new sp_Phone_DM();
            secondaryTestVolPhone.PhoneNbr = "2468013579";
            secondaryTestVolPhone.VolID = volID;
            secondaryTestVolPhone.ActiveFlg = true;
            secondaryTestVolPhone.PrimaryFlg = false;
            volPhone_bll.InsertPhoneContext(secondaryTestVolPhone);
        }
Пример #3
0
        public sp_Phone_DM hSelectPrimaryVolPhone(sp_Phone_DM givenPhone)
        {
            sp_Phone_DM Phone = new sp_Phone_DM();
            sp_VolPhone_BLL VolPhoneBll = new sp_VolPhone_BLL();

            Phone = VolPhoneBll.ListPrimaryPhone(givenPhone);
            return Phone;
        }
Пример #4
0
        public List<sp_Phone_DM> hSelectVolPhone(sp_Phone_DM givenPhone)
        {
            List<sp_Phone_DM> PhoneList = new List<sp_Phone_DM>();
            sp_VolPhone_BLL VolPhoneBll = new sp_VolPhone_BLL();

            PhoneList = VolPhoneBll.ListPhones(givenPhone);
            return PhoneList;
        }
Пример #5
0
        public void hUpdateVolPhone(sp_Phone_DM Phone, string phoneNumber,bool primaryNumber)
        {
            sp_VolPhone_BLL VolPhoneBll = new sp_VolPhone_BLL();

            Phone.PhoneNbr = phoneNumber;
            Phone.PrimaryFlg = primaryNumber;

            VolPhoneBll.UpdatePhoneNbr(Phone);
        }
Пример #6
0
 public void DeletePhonesContext(sp_Phone_DM cPhone)
 {
     System.Web.Caching.Cache cache = HttpRuntime.Cache;
     sp_Phone_DM cachePhones = (sp_Phone_DM)cache[RecordType.VolPhone + "|" + cPhone.VolID];
     if (cachePhones != null)
     {
         cache.Remove(RecordType.VolPhone + "|" + cPhone.VolID);
     }
     BLL.DeletePhonesContext(cPhone);
 }
Пример #7
0
 public List<sp_Phone_DM> ListPhones(sp_Phone_DM cPhone)
 {
     System.Web.Caching.Cache cache = HttpRuntime.Cache;
     List<sp_Phone_DM> cachePhones = (List<sp_Phone_DM>)cache["" + RecordType.VolPhoneList];
     if (cachePhones == null)
     {
         cachePhones = BLL.ListPhones(cPhone);
         cache.Insert(RecordType.VolPhoneList + "|" + cPhone.VolID.ToString(), cPhone, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
     }
     return cachePhones;
 }
Пример #8
0
        /// <summary>
        /// DeletePhonesContext - Will do a soft delete (make inactive) by PhoneID
        /// </summary>
        /// <param name="_cVolunteer"></param>
        public void DeletePhonesContext(sp_Phone_DM _cPhone)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var PhonesToRemove = (from n in context.tblVolPhones where n.PhoneID == _cPhone.PhoneID select n).FirstOrDefault();
                PhonesToRemove.ActiveFlg = false;
                context.sp_Vol_Phone_Update(PhonesToRemove.PhoneID, PhonesToRemove.VolID, PhonesToRemove.PhoneNbr,
                    PhonesToRemove.ActiveFlg, PhonesToRemove.PrimaryFlg);
                context.SaveChanges();

            }
        }
Пример #9
0
        public sp_Phone_DM ListPrimaryPhone(sp_Phone_DM cPhone)
        {
            System.Web.Caching.Cache cache = HttpRuntime.Cache;
            sp_Phone_DM cachePhones = (sp_Phone_DM)cache[RecordType.VolPhonePrimary + "|" + cPhone.PhoneID];

            if (cachePhones == null)
            {
                cachePhones = BLL.ListPrimaryPhone(cPhone);
                if (cachePhones != null)
                {
                    cache.Insert("" + RecordType.VolPhonePrimary + "|" + cPhone.VolID.ToString(), cPhone, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
                }
            }
            return cachePhones;
        }
Пример #10
0
        public sp_Phone_DM hCreateVolPhone(string PhoneNbr,Guid VolID,bool primaryPhone,ref int numberPhones)
        {
            sp_Phone_DM Phone = new sp_Phone_DM();
            sp_VolPhone_BLL VolPhoneBll = new sp_VolPhone_BLL();

            numberPhones = numberPhones + 1;
            Phone.PhoneID = numberPhones;
            Phone.ActiveFlg = true;
            Phone.PhoneNbr = PhoneNbr;
            Phone.VolID = VolID;
            Phone.PrimaryFlg = primaryPhone;

            VolPhoneBll.InsertPhoneContext(Phone);

            return Phone;
        }
Пример #11
0
        /// <summary>
        /// InsertPhoneContext - Will insert a record into Volunteer Phone table via SProc
        /// </summary>
        /// <param name="_cVolunteer"></param>
        public void InsertPhoneContext(sp_Phone_DM _cPhone)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var cPhone = new tblVolPhone
                {
                    VolID = _cPhone.VolID,
                    PhoneID = _cPhone.PhoneID,
                    PhoneNbr = _cPhone.PhoneNbr,
                    ActiveFlg = _cPhone.ActiveFlg,
                    PrimaryFlg = _cPhone.PrimaryFlg
                };
                context.tblVolPhones.Add(cPhone);
                context.SaveChanges();

                _cPhone.PhoneID = cPhone.PhoneID;
            }
        }
Пример #12
0
        private static bool PhoneListContains(List<sp_Phone_DM> phoneList, sp_Phone_DM phone)
        {
            bool listContainsPhone = false;

            foreach (sp_Phone_DM currPhone in phoneList)
            {

                listContainsPhone = listContainsPhone || PhoneEquals(currPhone, phone);

            }

            return listContainsPhone;
        }
Пример #13
0
 private static bool PhoneEquals(sp_Phone_DM dm1, sp_Phone_DM dm2)
 {
     return ((dm1.ActiveFlg == dm2.ActiveFlg) &&
         (dm1.PhoneNbr == dm2.PhoneNbr) &&
         (dm1.PhoneID == dm2.PhoneID) &&
         (dm1.PrimaryFlg == dm2.PrimaryFlg) &&
         (dm1.VolID == dm2.VolID));
 }
Пример #14
0
 private static List<sp_Phone_DM> getVolPhoneDMs(DataTable dataTable)
 {
     List<sp_Phone_DM> volPhoneDMs = new List<sp_Phone_DM>();
     for (int i = 0; i < dataTable.Rows.Count; i++)
     {
         sp_Phone_DM returnPhone = new sp_Phone_DM();
         returnPhone.VolID = new Guid((string)dataTable.Rows[i]["VolID"]);
         returnPhone.PhoneNbr = (dataTable.Rows[i]["PhoneNbr"]).ToString();
         returnPhone.PrimaryFlg = Convert.ToBoolean(dataTable.Rows[i]["PrimaryFlg"]);
         returnPhone.PhoneID = Convert.ToInt32(dataTable.Rows[i]["PhoneID"]);
         returnPhone.ActiveFlg = Convert.ToBoolean(dataTable.Rows[i]["ActiveFlg"]);
         volPhoneDMs.Add(returnPhone);
     }
     return volPhoneDMs;
 }
Пример #15
0
        public void TestVolPhoneUpdate()
        {
            sp_VolPhone_BLL volPhoneBLL = new sp_VolPhone_BLL();
            sp_Phone_DM updatePhone = volPhoneBLL.ListPrimaryPhone(primaryTestVolPhone);
            String newPhoneNbr = "9876543210";
            updatePhone.PhoneNbr = newPhoneNbr;
            volPhoneBLL.UpdatePhoneNbr(updatePhone);
            sp_Phone_DM selectedPhone = volPhoneBLL.ListPrimaryPhone(updatePhone);
            primaryTestVolPhone.PhoneNbr = newPhoneNbr;

            //To get all phones listed, create a new domain model with no phoneID specified.
            sp_Phone_DM selectAllPhones = new sp_Phone_DM();
            selectAllPhones.VolID = updatePhone.VolID;
            List<sp_Phone_DM> selectedPhoneList = volPhoneBLL.ListPhones(selectAllPhones);

            Assert.IsTrue(PhoneListContains(selectedPhoneList, updatePhone));
            Assert.IsTrue(PhoneListContains(selectedPhoneList, secondaryTestVolPhone));
            Assert.IsTrue(PhoneEquals(selectedPhone, updatePhone));
            Assert.AreEqual(newPhoneNbr, selectedPhone.PhoneNbr);
        }
Пример #16
0
 public List<sp_Phone_DM> ListPhones(sp_Phone_DM cVolPhone)
 {
     return DAL.ListPhones(cVolPhone);
 }
Пример #17
0
 public sp_Phone_DM ListPrimaryPhone(sp_Phone_DM cVolPhone)
 {
     return DAL.ListPrimaryPhone(cVolPhone);
 }
Пример #18
0
 public void UpdatePhoneNbr(sp_Phone_DM _cPhone)
 {
     DAL.UpdatePhoneNbr(_cPhone);
 }
Пример #19
0
 public void InsertPhoneContext(sp_Phone_DM _cPhone)
 {
     DAL.InsertPhoneContext(_cPhone);
 }
Пример #20
0
        /// <summary>
        /// rGridPhone_UpdIns - Handle update/insert in a common procedure
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="iAction"></param>
        protected void rGridPhone_UpdIns(object sender, GridCommandEventArgs e, int iAction)
        {
            try
            {
                GridEditableItem eeditedItem = e.Item as GridEditableItem;

                sp_Phone_DM VolPhoneDM = new sp_Phone_DM();
                VolPhoneDM.VolID = (Guid)currentUser.ProviderUserKey;

                if (iAction == (int)RecordAction.Update)
                {

                    VolPhoneDM.PhoneID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["PhoneID"]);
                 }
                VolPhoneDM.ActiveFlg = (eeditedItem.FindControl("chkActive") as CheckBox).Checked;
                VolPhoneDM.PrimaryFlg = (eeditedItem.FindControl("chkPrimaryFlg") as CheckBox).Checked;
                VolPhoneDM.PhoneNbr = (eeditedItem.FindControl("rTBPhone") as RadTextBox).Text.ToString();
               // VolPhoneDM.AddrLine2 = (eeditedItem.FindControl("rTBPhone2") as RadTextBox).Text.ToString();
              //  VolPhoneDM.AddrLine3 = (eeditedItem.FindControl("rTBPhone3") as RadTextBox).Text.ToString();

                if (iAction == (int)RecordAction.Update)
                {
                    VolPhoneBLL.UpdatePhoneNbr(VolPhoneDM);
                   // VolAddrBLL.UpdateAddressContext(VolAddressDM, VolAddrDM);

                }
                else if (iAction == (int)RecordAction.Insert)
                {
                    VolPhoneBLL.InsertPhoneContext(VolPhoneDM);
                   // VolPhoneBLL.InsertAddressContext(ref VolPhoneDM, ref VolPhoDM);
                }
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.
            }

            try
            {
                HandleScreenLoad();
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.
            }
        }
Пример #21
0
        /// <summary>
        /// rGridAddress_DeleteCommand - Handle the delete command
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rGridPhone_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            sp_Phone_DM VolPhoneDM = new sp_Phone_DM();

            try
            {
                VolPhoneDM.VolID = (Guid)currentUser.ProviderUserKey;
                VolPhoneDM.PhoneID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PhoneID"];

                VolPhoneBLL.DeletePhonesContext(VolPhoneDM);
                // VolPhoneBLL.DeleteAddressContext(VolPhoneDM, VolPhoDM);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.

            }
        }
Пример #22
0
        public void TestVolPhoneCreate()
        {
            sp_Volunteer_BLL vol_bll = new sp_Volunteer_BLL();
            sp_Volunteer_DM vol_dm = new sp_Volunteer_DM();
            vol_dm.VolFirstName = "createFirst";
            vol_dm.VolMiddleName = "createMiddle";
            vol_dm.VolLastName = "createLast";
            vol_dm.ActiveFlg = true;
            System.Guid volID = vol_bll.InsertVolunteerContext(ref vol_dm).VolID;
            vol_dm.VolID = volID;

            string volPhoneNbr = "0123456789";
            bool PrimaryFlg = true;
            bool ActiveFlg = true;
            sp_VolPhone_BLL volPhone_bll = new sp_VolPhone_BLL();
            sp_Phone_DM volPhone_dm = new sp_Phone_DM();
            volPhone_dm.PhoneNbr = volPhoneNbr;
            volPhone_dm.VolID = volID;
            volPhone_dm.ActiveFlg = ActiveFlg;
            volPhone_dm.PrimaryFlg = PrimaryFlg;
            volPhone_bll.InsertPhoneContext(volPhone_dm);
            int volPhoneID = volPhone_dm.PhoneID;

            List<sp_Phone_DM> volPhoneDMs_selected = volPhone_bll.ListPhones(volPhone_dm);
            Assert.IsTrue(PhoneListContains(volPhoneDMs_selected, volPhone_dm));
        }
Пример #23
0
        /// <summary>
        /// UpdatePhoneAddr - Will update a given PhoneNbr record by PhoneID
        /// </summary>
        /// <param name="_cVolunteer"></param>
        public void UpdatePhoneNbr(sp_Phone_DM _cPhone)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var cPhone = context.tblVolPhones.Find(_cPhone.PhoneID, _cPhone.VolID);

                if (cPhone != null)
                {
                    cPhone.PhoneID = _cPhone.PhoneID;
                    cPhone.PhoneNbr = _cPhone.PhoneNbr;
                    cPhone.VolID = _cPhone.VolID;
                    cPhone.ActiveFlg = _cPhone.ActiveFlg;
                    cPhone.PrimaryFlg = _cPhone.PrimaryFlg;
                    context.SaveChanges();
                }
            }
        }
Пример #24
0
 public void InsertPhoneContext(sp_Phone_DM cPhone)
 {
     BLL.InsertPhoneContext(cPhone);
     System.Web.Caching.Cache cache = HttpRuntime.Cache;
     cache.Insert(RecordType.VolPhone + "|" + cPhone.VolID, cPhone, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
 }
Пример #25
0
        protected void HandleScreenLoad()
        {
            currentUser = Membership.GetUser();

            //pnlSingleAddress.Visible = false;
            pnlPhoneGrid.Visible = true;
            //sp_Vol_Address_DM VolDM = new sp_Vol_Address_DM();
            sp_Phone_DM VolDM = new sp_Phone_DM();
            VolDM.VolID = (Guid)currentUser.ProviderUserKey;
            //rGridAddress.DataSource = VolAddrBLL.ListAddresses(VolDM);

            rGridPhone.DataSource = VolPhoneCash.ListPhones(VolDM);
            rGridPhone.DataBind();
        }
Пример #26
0
 public void UpdatePhoneNbr(sp_Phone_DM cPhone)
 {
     System.Web.Caching.Cache cache = HttpRuntime.Cache;
     sp_Phone_DM cachePhones = (sp_Phone_DM)cache[RecordType.VolPhone + "|" + cPhone.VolID];
     if (cachePhones != null)
     {
         cache.Remove(RecordType.VolPhone + "|" + cPhone.VolID);
     }
     cache.Insert(RecordType.VolPhone + "|" + cPhone.VolID, cPhone, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
     BLL.UpdatePhoneNbr(cPhone);
 }
Пример #27
0
        /// <summary>
        /// rGridEmail_NeedDataSource - Called when the grid needs a data source
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rGridPhone_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            try
            {
                sp_Phone_DM VolDM = new sp_Phone_DM();
                VolDM.VolID = (Guid)currentUser.ProviderUserKey;
                //rGridAddress.DataSource = VolAddrBLL.ListAddresses(VolDM);

                rGridPhone.DataSource = VolPhoneCash.ListPhones(VolDM);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.

            }
        }
Пример #28
0
        public void hDeleteVolPhone(sp_Phone_DM Phone)
        {
            sp_VolPhone_BLL VolPhoneBll = new sp_VolPhone_BLL();

            VolPhoneBll.DeletePhonesContext(Phone);
        }
Пример #29
0
        /// <summary>
        /// SetPrimaryValues - Paint the screen with default values (use non-telerik controls)
        /// </summary>
        protected void SetPrimaryValues()
        {
            //setup and bind all 3 primary values
            currentUser = Membership.GetUser();
            sp_Vol_Address_DM address_DM = new sp_Vol_Address_DM();
            sp_Email_DM email_DM = new sp_Email_DM();
            sp_Phone_DM phone_DM = new sp_Phone_DM();
            StringBuilder sb = new StringBuilder();

            try
            {
                //email code
                email_DM.VolID = (Guid)currentUser.ProviderUserKey;
                email_DM = VolEmailCache.ListPrimaryEmail(email_DM);
                if (email_DM != null)
                {
                    PrimaryEmail.Text = email_DM.EmailAddr;
                }
                else
                {
                    PrimaryEmail.Text = "-- NONE --";
                }

                //phone code
                phone_DM.VolID = (Guid)currentUser.ProviderUserKey;
                phone_DM = VolPhoneCache.ListPrimaryPhone(phone_DM);

                if (phone_DM != null)
                {
                    PrimaryPhone.Text = phone_DM.PhoneNbr;
                }
                else
                {
                    PrimaryPhone.Text = "-- NONE --";
                }

                //address code
                address_DM.VolID = (Guid)currentUser.ProviderUserKey;
                address_DM = VolAddrCash.ListPrimaryAddress(address_DM);

                sb.Clear();
                if (address_DM != null)
                {
                    sb.Append(address_DM.AddrLine1.ToString());
                    sb.Append(" ");
                    if (!string.IsNullOrEmpty(address_DM.AddrLine2))
                    {
                        sb.Append(address_DM.AddrLine2.ToString());
                        sb.Append(" ");
                    }
                    if (!string.IsNullOrEmpty(address_DM.AddrLine3))
                    {
                        sb.Append(address_DM.AddrLine3.ToString());
                        sb.Append(" ");
                    }
                    sb.Append(", ");
                    sb.Append(address_DM.City.ToString());
                    sb.Append(" ");
                    sb.Append(address_DM.St.ToString());
                    sb.Append(",  ");
                    sb.Append(address_DM.Zip.ToString());
                    if (!string.IsNullOrEmpty(address_DM.Zip4.ToString()))
                    {
                        sb.Append('-');
                        sb.Append(address_DM.Zip4.ToString());
                    }
                }
                PrimaryAddress.Text = sb.ToString();

            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.
            }
        }
Пример #30
0
 public void DeletePhonesContext(sp_Phone_DM _cPhone)
 {
     DAL.DeletePhonesContext(_cPhone);
 }