Пример #1
0
        /// <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);
                }

            }
        }