/// <summary>
        /// DeleteAddressContext - Will do a soft delete (make inactive) by AddrID
        /// </summary>
        /// <param name="_cAddress"></param>
        public void DeleteAddressContext(sp_Vol_Address_DM _cAddress, sp_Vol_Addr_DM _cVolAddr)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                try
                {
                    var AddrToRemove = (from n in context.tblVolAddrs where n.AddrID == _cVolAddr.AddrID select n).FirstOrDefault();
                    if (AddrToRemove != null)
                        context.tblVolAddrs.Remove(AddrToRemove);
                    context.SaveChanges();

                    var AddressToRemove = (from n in context.tblVolAddresses where n.AddrID == _cAddress.AddrID select n).FirstOrDefault();
                    //context.tblVolAddresses.Remove(AddressToRemove);
                    AddressToRemove.ActiveFlg = false;
                    if (AddressToRemove != null)
                        context.sp_Vol_Address_Update(AddressToRemove.AddrID, AddressToRemove.ActiveFlg, AddressToRemove.AddrLine1,
                            AddressToRemove.AddrLine2, AddressToRemove.AddrLine3, AddressToRemove.City, AddressToRemove.St, AddressToRemove.Zip,
                            AddressToRemove.Zip4, AddressToRemove.GeoCodeGetSet);
                    context.SaveChanges();

                }
                catch (Exception ex)
                {
                    throw (ex);
                }

            }
        }
        /// <summary>
        /// DeleteAddressContext - Remove from cache and call delete method in BLL.
        /// </summary>
        /// <param name="_cAddress"></param>
        /// <param name="_cVolAddr"></param>
        public void DeleteAddressContext(sp_Vol_Address_DM _cAddress, sp_Vol_Addr_DM _cVolAddr)
        {
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            sp_Vol_Address_DM cacheAddress;
            cacheAddress = (sp_Vol_Address_DM)cache[RecordType.VolAddr + _cVolAddr.VolID.ToString() + _cAddress.AddrID.ToString()];

            if (cacheAddress != null)
            {
                cache.Remove(RecordType.VolAddr + "|" + _cVolAddr.VolID.ToString() + "|" + _cAddress.AddrID.ToString());
            }
            BLL.DeleteAddressContext(_cAddress, _cVolAddr);
        }
Exemple #3
0
        public static void InsertVolAddressData(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;
            generalTestVol.VolID = Guid.NewGuid();
            volBLL.InsertVolunteerContext(ref generalTestVol);

            sp_Vol_Address_BLL volAddress_bll = new sp_Vol_Address_BLL();
            primaryTestVolAddress = new sp_Vol_Address_DM();
            primaryTestVolAddress.AddrLine1 = "PrimaryLine1";
            primaryTestVolAddress.AddrLine2 = "PrimaryLine2";
            primaryTestVolAddress.AddrLine3 = "PrimaryLine3";
            primaryTestVolAddress.City = "PrimaryCity";
            primaryTestVolAddress.St = "PS";
            primaryTestVolAddress.Zip = 12345;
            primaryTestVolAddress.Zip4 = 6789;
            primaryTestVolAddress.VolID = generalTestVol.VolID;
            primaryTestVolAddress.ActiveFlg = true;
            primaryTestVolAddress.PrimaryAddr = true;

            primaryTestVolAddr = new sp_Vol_Addr_DM();
            primaryTestVolAddr.VolID = generalTestVol.VolID;
            primaryTestVolAddr.PrimaryAddr = true;

            volAddress_bll.InsertAddressContext(ref primaryTestVolAddress, ref primaryTestVolAddr);

            secondaryTestVolAddress = new sp_Vol_Address_DM();
            secondaryTestVolAddress.AddrLine1 = "SecondaryLine1";
            secondaryTestVolAddress.AddrLine2 = "SecondaryLine2";
            secondaryTestVolAddress.AddrLine3 = "SecondaryLine3";
            secondaryTestVolAddress.City = "SecondaryCity";
            secondaryTestVolAddress.St = "SS";
            secondaryTestVolAddress.Zip = 98765;
            secondaryTestVolAddress.Zip4 = 4321;
            secondaryTestVolAddress.VolID = generalTestVol.VolID;
            secondaryTestVolAddress.ActiveFlg = true;
            secondaryTestVolAddress.PrimaryAddr = false;

            secondaryTestVolAddr = new sp_Vol_Addr_DM();
            secondaryTestVolAddr.VolID = generalTestVol.VolID;
            secondaryTestVolAddr.PrimaryAddr = false;
            volAddress_bll.InsertAddressContext(ref secondaryTestVolAddress, ref secondaryTestVolAddr);
        }
        /// <summary>
        /// InsertAddressContext - Will insert a record into Address table via SProc
        /// </summary>
        /// <param name="_cAddress"></param>
        public void InsertAddressContext(ref sp_Vol_Address_DM _cAddress, ref sp_Vol_Addr_DM _cVolAddr)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                try
                {
                    var cAddress = new tblVolAddress
                    {
                        AddrLine1 = _cAddress.AddrLine1,
                        AddrLine2 = _cAddress.AddrLine2,
                        AddrLine3 = _cAddress.AddrLine3,
                        City = _cAddress.City,
                        St = _cAddress.St,
                        Zip = _cAddress.Zip,
                        Zip4 = _cAddress.Zip4,
                        GeoCodeGetSet = _cAddress.GeoCodeGetSet,
                        ActiveFlg = _cAddress.ActiveFlg
                    };
                    context.tblVolAddresses.Add(cAddress);
                    context.SaveChanges();

                    var cVolAddr = new tblVolAddr
                    {
                        VolID = _cVolAddr.VolID,
                        AddrID = cAddress.AddrID,
                        PrimaryAddr = _cVolAddr.PrimaryAddr
                    };

                    context.tblVolAddrs.Add(cVolAddr);
                    context.SaveChanges();

                    //If the AddrID isn't null, set it equal to the return value
                    if (cAddress.AddrID != null)
                        _cAddress.AddrID = cAddress.AddrID;

                    if (cVolAddr.AddrID != null)
                        _cVolAddr.AddrID = cVolAddr.AddrID;
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }
        }
Exemple #5
0
        public sp_Vol_Address_DM hCreateVolAddress(string AddrLine1,string AddrLine2,string AddrLine3,string City,string State,Nullable<int> Zip,Nullable<int> Zip4,bool PrimaryAddr,Guid VolID)
        {
            sp_Vol_Address_DM VolAddress = new sp_Vol_Address_DM();
            sp_Vol_Addr_DM VolAddr = new sp_Vol_Addr_DM();
            sp_Vol_Address_BLL VolAddressBll = new sp_Vol_Address_BLL();

            VolAddress.AddrLine1 = AddrLine1;
            VolAddress.AddrLine2 = AddrLine2;
            VolAddress.AddrLine3 = AddrLine3;
            VolAddress.City = City;
            VolAddress.St = State;
            VolAddress.Zip = Zip;
            VolAddress.Zip4 = Zip4;

            VolAddr.VolID = VolID;
            VolAddr.PrimaryAddr = PrimaryAddr;

            VolAddressBll.InsertAddressContext(ref VolAddress,ref VolAddr);

            return VolAddress;
        }
Exemple #6
0
        /// <summary>
        /// rGridAdress_UpdIns - Handle update/insert in a common procedure
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="iAction"></param>
        protected void rGridAdress_UpdIns(object sender, GridCommandEventArgs e, int iAction)
        {
            try
            {
                GridEditableItem eeditedItem = e.Item as GridEditableItem;

                sp_Vol_Address_DM VolAddressDM = new sp_Vol_Address_DM();
                sp_Vol_Addr_DM VolAddrDM = new sp_Vol_Addr_DM();

                VolAddrDM.VolID = (Guid)currentUser.ProviderUserKey; ;

                VolAddressDM.VolID = (Guid)currentUser.ProviderUserKey;
                if (iAction == (int)RecordAction.Update)
                {
                    VolAddressDM.AddrID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
                    pre_ID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
                    VolAddrDM.AddrID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
                }
                VolAddressDM.ActiveFlg = (eeditedItem.FindControl("chkActive") as CheckBox).Checked;
                VolAddrDM.PrimaryAddr = (eeditedItem.FindControl("chkPrimaryAddr") as CheckBox).Checked;

                VolAddressDM.AddrLine1 = (eeditedItem.FindControl("rTBAddr1") as RadTextBox).Text.ToString();
                VolAddressDM.AddrLine2 = (eeditedItem.FindControl("rTBAddr2") as RadTextBox).Text.ToString();
                VolAddressDM.AddrLine3 = (eeditedItem.FindControl("rTBAddr3") as RadTextBox).Text.ToString();
                VolAddressDM.City = (eeditedItem.FindControl("rTBCity") as RadTextBox).Text.ToString();
                VolAddressDM.St = (eeditedItem.FindControl("rDDSt") as RadDropDownList).SelectedValue.ToString();
                VolAddressDM.Zip = Convert.ToInt32((eeditedItem.FindControl("rNTBZip") as RadNumericTextBox).Text);
                string strZip4 = ((eeditedItem.FindControl("rNTBZip4") as RadNumericTextBox).Text).ToString();
                if (strZip4 == string.Empty)
                {
                    VolAddressDM.Zip4 = null;
                }
                else
                {
                    VolAddressDM.Zip4 = Convert.ToInt32(strZip4.ToString());
                }
                //TODO - Test to see if GeoCode works without USA at end
                //   VolAddressDM.GeoCodeGetSet = GetGeoCode(VolAddressDM);

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

                }
                else if (iAction == (int)RecordAction.Insert)
                {
                    VolAddrBLL.InsertAddressContext(ref VolAddressDM, ref VolAddrDM);
                }
            }
            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.
            }
        }
Exemple #7
0
        /// <summary>
        /// rGridAddress_DeleteCommand - Handle the delete command
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rGridAddress_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            sp_Vol_Address_DM VolAddressDM = new sp_Vol_Address_DM();
            sp_Vol_Addr_DM VolAddrDM = new sp_Vol_Addr_DM();

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

                VolAddrDM.VolID = (Guid)currentUser.ProviderUserKey;
                VolAddrDM.AddrID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AddrID"];

                VolAddrBLL.DeleteAddressContext(VolAddressDM, VolAddrDM);
            }
            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.

            }
        }
 public void UpdateAddressContext(sp_Vol_Address_DM _cAddress, sp_Vol_Addr_DM _cVolAddr)
 {
     DAL.UpdateAddressContext(_cAddress, _cVolAddr);
 }
 public void InsertAddressContext(ref sp_Vol_Address_DM _cAddress, ref sp_Vol_Addr_DM _cVolAddr)
 {
     DAL.InsertAddressContext(ref _cAddress, ref _cVolAddr);
 }
 public void DeleteAddressContext(sp_Vol_Address_DM _cAddress, sp_Vol_Addr_DM _cVolAddr)
 {
     DAL.DeleteAddressContext(_cAddress, _cVolAddr);
 }
        /// <summary>
        /// UpdateAddressContext - Will update a given Address record by AddrID
        /// </summary>
        /// <param name="_cAddress"></param>
        public void UpdateAddressContext(sp_Vol_Address_DM _cAddress, sp_Vol_Addr_DM _cVolAddr)
        {
            try
            {
                using (VolTeerEntities context = new VolTeerEntities())
                {
                    var cAddress = context.tblVolAddresses.Find(_cAddress.AddrID);
                    var cVolAddr = context.tblVolAddrs.Find(_cVolAddr.VolID,_cVolAddr.AddrID);

                    if (cAddress != null)
                    {
                        cAddress.AddrLine1 = _cAddress.AddrLine1;
                        cAddress.AddrLine2 = _cAddress.AddrLine2;
                        cAddress.AddrLine3 = _cAddress.AddrLine3;
                        cAddress.City = _cAddress.City;
                        cAddress.St = _cAddress.St;
                        cAddress.Zip = _cAddress.Zip;
                        cAddress.Zip4 = _cAddress.Zip4;
                        cAddress.ActiveFlg = _cAddress.ActiveFlg;
                        cAddress.GeoCodeGetSet = _cAddress.GeoCodeGetSet;
                    }

                    if (cVolAddr != null)
                    {
                        cVolAddr.VolID = _cVolAddr.VolID;
                        cVolAddr.AddrID = _cVolAddr.AddrID;
                        cVolAddr.PrimaryAddr = _cVolAddr.PrimaryAddr;
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
 /// <summary>
 /// InsertAddressContext - Insert a new address into cache, then call BLL to add to database.
 /// </summary>
 /// <param name="_cAddress"></param>
 /// <param name="_cVolAddr"></param>
 public void InsertAddressContext(ref sp_Vol_Address_DM _cAddress, ref sp_Vol_Addr_DM _cVolAddr)
 {
     BLL.InsertAddressContext(ref _cAddress, ref _cVolAddr);
     System.Web.Caching.Cache cache = HttpRuntime.Cache;
     cache.Insert(RecordType.VolAddr + "|" + _cVolAddr.VolID.ToString() + "|" + _cAddress.AddrID.ToString(), _cAddress, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
 }
        /// <summary>
        /// UpdateAddressContext - Record is updated, remove from cache, add back to cache, and then call BLL to update database.
        /// </summary>
        /// <param name="_cAddress"></param>
        /// <param name="_cVolAddr"></param>
        public void UpdateAddressContext(sp_Vol_Address_DM _cAddress, sp_Vol_Addr_DM _cVolAddr)
        {
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            sp_Vol_Address_DM cacheAddress;
            cacheAddress = (sp_Vol_Address_DM)cache[_cAddress.AddrID.ToString()];

            if (cacheAddress != null)
            {
                cache.Remove(RecordType.VolAddr + "|" + _cVolAddr.VolID.ToString() + "|" + _cAddress.AddrID.ToString());
            }

            cache.Insert(RecordType.VolAddr + _cVolAddr.VolID.ToString() + _cAddress.AddrID.ToString(), _cAddress, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
            BLL.UpdateAddressContext(_cAddress, _cVolAddr);
        }
Exemple #14
0
        public void TestVolAddressCreate()
        {
            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 = Guid.NewGuid();
            vol_dm.VolID = volID;
            createTestVol = vol_dm;
            vol_bll.InsertVolunteerContext(ref vol_dm);

            string volAddr1 = "CreateLine1";
            string volAddr2 = "CreateLine2";
            string volAddr3 = "CreateLine3";
            string volCity = "CreateCity";
            string volSt = "CS";
            int volZip = 13579;
            int volZip4 = 2468;
            bool PrimaryFlg = true;
            bool ActiveFlg = true;
            sp_Vol_Address_BLL volAddress_bll = new sp_Vol_Address_BLL();
            sp_Vol_Address_DM volAddress_dm = new sp_Vol_Address_DM();
            sp_Vol_Addr_DM volAddr_dm = new sp_Vol_Addr_DM();

            volAddress_dm.ActiveFlg = ActiveFlg;
            volAddress_dm.AddrLine1 = volAddr1;
            volAddress_dm.AddrLine2 = volAddr2;
            volAddress_dm.AddrLine3 = volAddr3;
            volAddress_dm.City = volCity;
            volAddress_dm.St = volSt;
            volAddress_dm.Zip = volZip;
            volAddress_dm.Zip4 = volZip4;
            volAddress_dm.VolID = volID;
            volAddress_dm.PrimaryAddr = PrimaryFlg;

            volAddr_dm.PrimaryAddr = PrimaryFlg;
            volAddr_dm.VolID = volID;

            volAddress_bll.InsertAddressContext(ref volAddress_dm, ref volAddr_dm);

            sp_Vol_Address_DM volAddressDMs_selected = volAddress_bll.ListAddress(volAddress_dm);
            Assert.IsTrue(AddressEquals(volAddressDMs_selected, volAddress_dm));
        }