Exemplo n.º 1
0
        public void DeleteAddressContext(sp_Vol_Address_DM _cAddress, sp_GroupAddr_DM _cGroupAddr)
        {
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            sp_GroupAddr_DM cacheAddress;
            cacheAddress = (sp_GroupAddr_DM)cache[_cGroupAddr.GroupID.ToString() + _cAddress.AddrID.ToString()];

            if (cacheAddress != null)
            {
                cache.Remove(_cGroupAddr.GroupID.ToString() + "|" + _cAddress.AddrID.ToString());
            }
            BLL.DeleteAddressContext(_cAddress, _cGroupAddr);
        }
Exemplo n.º 2
0
        public void TestGroupAddrCreate()
        {
            var group_bll = new sp_Group_BLL();
            var groupAddr_bll = new sp_GroupAddr_BLL();
            var groupAddr_dm = new sp_GroupAddr_DM();
            var allGroups = group_bll.ListGroups();
            Assert.IsTrue(allGroups.Count > 0, "The allGroups() is broken, or no data in DB");
            groupAddr_dm.GroupID = allGroups[0].GroupID;
            groupAddr_dm.PrimaryAddrID = true;
            groupAddr_dm.ActiveFlg = true;
            var volAddress_bll = new sp_Vol_Address_BLL();
            var volAddress_dm = volAddress_bll.ListAddress(new sp_Vol_Address_DM());
            groupAddr_bll.InsertAddressContext(ref volAddress_dm, ref groupAddr_dm);
            groupAddr_dm.AddrID = volAddress_dm.AddrID;

            var groupAddr_dm_selected = groupAddr_bll.ListAddress(groupAddr_dm);
            Assert.IsTrue(Equals(groupAddr_dm, groupAddr_dm_selected));
        }
Exemplo n.º 3
0
        public void InsertAddressContext(ref sp_Vol_Address_DM _cAddress, ref sp_GroupAddr_DM _cGroupAddr)
        {
            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 cGroupAddr = new tblGroupAddr
                    {
                        GroupID = _cGroupAddr.GroupID,
                        AddrID = cAddress.AddrID,
                        PrimaryAddrID = _cGroupAddr.PrimaryAddrID
                    };

                    context.tblGroupAddrs.Add(cGroupAddr);
                    context.SaveChanges();

                    //If the AddrID isn't null, set it equal to the return value
                    if (_cAddress.AddrID != null)
                    {
                        _cAddress.AddrID = cAddress.AddrID;
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }
        }
Exemplo n.º 4
0
        public List<sp_GroupAddr_DM> ListAddresses(sp_GroupAddr_DM cGroupAddr)
        {
            List<sp_GroupAddr_DM> cAddress = new List<sp_GroupAddr_DM>();

            //Cache cache = HttpRuntime.Cache;
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            List<sp_GroupAddr_DM> cacheAddress;
            cacheAddress = (List<sp_GroupAddr_DM>)cache[cGroupAddr.GroupID.ToString()];

            if (cacheAddress == null)
            {
                cAddress = BLL.ListAddresses(cGroupAddr);
                cache.Insert(cGroupAddr.GroupID.ToString(), cAddress, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
            }
            else
            {
                cAddress = cacheAddress;
            }
            return cAddress;
        }
Exemplo n.º 5
0
        public void DeleteAddressContext(sp_Vol_Address_DM _cAddress, sp_GroupAddr_DM _cGroupAddr)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                try
                {
                    var AddrToRemove = (from n in context.tblGroupAddrs where n.AddrID == _cGroupAddr.AddrID select n).FirstOrDefault();
                    context.tblGroupAddrs.Remove(AddrToRemove);
                    context.SaveChanges();

                    var AddressToRemove = (from n in context.tblVolAddresses where n.AddrID == _cAddress.AddrID select n).FirstOrDefault();
                    context.tblVolAddresses.Remove(AddressToRemove);
                    context.SaveChanges();

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

            }
        }
Exemplo n.º 6
0
 public void InsertAddressContext(ref sp_Vol_Address_DM _cAddress, ref sp_GroupAddr_DM _cGroupAddr)
 {
     BLL.InsertAddressContext(ref _cAddress, ref _cGroupAddr);
     System.Web.Caching.Cache cache = HttpRuntime.Cache;
     cache.Insert(_cGroupAddr.GroupID.ToString() + "|" + _cAddress.AddrID.ToString(), _cAddress, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
 }
Exemplo n.º 7
0
 public void InsertAddressContext(ref sp_Vol_Address_DM _cAddress, ref sp_GroupAddr_DM _cGroupAddr)
 {
     DAL.InsertAddressContext(ref _cAddress, ref _cGroupAddr);
 }
Exemplo n.º 8
0
        public void UpdateAddressContext(sp_Vol_Address_DM _cAddress, sp_GroupAddr_DM _cGroupAddr)
        {
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

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

            if (cacheAddress != null)
            {
                cache.Remove(_cGroupAddr.GroupID.ToString() + "|" + _cAddress.AddrID.ToString());
            }

            cache.Insert(_cGroupAddr.GroupID.ToString() + _cAddress.AddrID.ToString(), _cAddress, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
            BLL.UpdateAddressContext(_cAddress, _cGroupAddr);
        }
Exemplo n.º 9
0
        public void UpdateAddressContext(sp_Vol_Address_DM _cAddress, sp_GroupAddr_DM _cGroupAddr)
        {
            try
            {
                using (VolTeerEntities context = new VolTeerEntities())
                {
                    var cAddress = context.tblVolAddresses.Find(_cAddress.AddrID);
                    var cGroupAddr = context.tblGroupAddrs.Find(_cGroupAddr.GroupID, _cGroupAddr.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 (cGroupAddr != null)
                    {
                        cGroupAddr.GroupID = _cGroupAddr.GroupID;
                        cGroupAddr.AddrID = _cGroupAddr.AddrID;
                        cGroupAddr.PrimaryAddrID = _cGroupAddr.PrimaryAddrID;
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 10
0
 public void UpdateAddressContext(sp_Vol_Address_DM _cAddress, sp_GroupAddr_DM _cGroupAddr)
 {
     DAL.UpdateAddressContext(_cAddress, _cGroupAddr);
 }
Exemplo n.º 11
0
        public sp_GroupAddr_DM ListPrimaryAddress(sp_GroupAddr_DM cGroupAddr)
        {
            sp_GroupAddr_DM cAddress = new sp_GroupAddr_DM();

            //Cache cache = HttpRuntime.Cache;
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            sp_GroupAddr_DM cacheAddress;
            cacheAddress = (sp_GroupAddr_DM)cache[cGroupAddr.GroupID.ToString()];

            if (cacheAddress == null)
            {
                cAddress = BLL.ListPrimaryAddress(cGroupAddr);
                cache.Insert(cGroupAddr.GroupID.ToString() + "|" + cAddress.AddrID.ToString(), cAddress, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callback);
            }
            else
            {
                cAddress = cacheAddress;
            }
            return cAddress;
        }
Exemplo n.º 12
0
 public List<sp_GroupAddr_DM> ListAddresses(sp_GroupAddr_DM cGroupAddr)
 {
     return DAL.ListAddresses(cGroupAddr);
 }
Exemplo n.º 13
0
 public sp_GroupAddr_DM ListPrimaryAddress(sp_GroupAddr_DM cGroupAddr)
 {
     return DAL.ListPrimaryAddress(cGroupAddr);
 }
Exemplo n.º 14
0
        public sp_GroupAddr_DM ListPrimaryAddress(sp_GroupAddr_DM cGroupAddr)
        {
            sp_GroupAddr_DM item = new sp_GroupAddr_DM();
            try
            {
                using (VolTeerEntities context = new VolTeerEntities())
                {
                    item = (from result in context.sp_GroupAddr_Select(cGroupAddr.GroupID, cGroupAddr.AddrID)
                            select new sp_GroupAddr_DM
                            {
                                GroupID = result.GroupID,
                                AddrID = result.AddrID,
                                PrimaryAddrID = result.PrimaryAddrID,
                                ActiveFlg = result.ActiveFlg
                            }).FirstOrDefault();
                } // Guaranteed to close the Connection
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return item;
        }
Exemplo n.º 15
0
 public sp_GroupAddr_DM ListAddress(sp_GroupAddr_DM cGroupAddr)
 {
     return ListAddresses(cGroupAddr).Single();
 }
Exemplo n.º 16
0
 bool Equals(sp_GroupAddr_DM dm1, sp_GroupAddr_DM dm2)
 {
     return (dm1.GroupID == dm2.GroupID &&
             dm1.AddrID == dm2.AddrID &&
             dm1.PrimaryAddrID == dm2.PrimaryAddrID &&
             dm1.ActiveFlg == dm2.ActiveFlg
             );
 }
Exemplo n.º 17
0
 private static List<sp_GroupAddr_DM> DMsFrom(DataTable dataTable)
 {
     var DMs = new List<sp_GroupAddr_DM>();
     for (int i = 0; i < dataTable.Rows.Count; i++)
     {
         var returnGroup = new sp_GroupAddr_DM();
         returnGroup.GroupID = Convert.ToInt32(dataTable.Rows[i]["GroupID"]);
         returnGroup.AddrID = Convert.ToInt32(dataTable.Rows[i]["AddrID"]);
         returnGroup.PrimaryAddrID = Convert.ToBoolean(dataTable.Rows[i]["PrimaryAddrID"]);
         returnGroup.ActiveFlg = Convert.ToBoolean(dataTable.Rows[i]["ActiveFlg"]);
         DMs.Add(returnGroup);
     }
     return DMs;
 }
Exemplo n.º 18
0
        public List<sp_GroupAddr_DM> ListAddresses(sp_GroupAddr_DM cGroupAddr)
        {
            List<sp_GroupAddr_DM> list = new List<sp_GroupAddr_DM>();
            try
            {
                using (VolTeerEntities context = new VolTeerEntities())
                {
                    list = (from result in context.sp_GroupAddr_Select(cGroupAddr.GroupID, cGroupAddr.AddrID)
                            select new sp_GroupAddr_DM
                            {
                                GroupID = result.GroupID,
                                AddrID = result.AddrID,
                                PrimaryAddrID = result.PrimaryAddrID,
                                ActiveFlg = result.ActiveFlg
                            }).ToList();
                } // Guaranteed to close the Connection
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return list;
        }