Example #1
0
        public bool DeleteListingServiceLocation(long listingServiceLocationId)
        {
            bool retVal = false;
            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    using (TMCContext tmcContext = new TMCContext())
                    {
                        ListingServiceLocation listingServiceLocationEntity = tmcContext.ListingServiceLocation.SingleOrDefault(lcid =>
                                                                      lcid.ListingServiceLocationId == listingServiceLocationId);

                        if (listingServiceLocationEntity != null)
                        {
                            tmcContext.DeleteObject(listingServiceLocationEntity);
                            tmcContext.SaveChanges();
                        }
                    }
                    trans.Complete();
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException("Error while deleting listing ServiceLocation.", ex);
            }
            return retVal;
        }
Example #2
0
        public string DeleteListingMedia(long listingMediaid)
        {
            string retVal = "";
            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    using (TMCContext tmcContext = new TMCContext())
                    {
                        ListingMedia listingMediaEntity = tmcContext.ListingMedia.SingleOrDefault(lm =>
                                                                      lm.ListingMediaId == listingMediaid); //todo check
                        File fileEntity = tmcContext.File.SingleOrDefault(f =>
                                                                      f.FileId == listingMediaEntity.FileId);

                        if (listingMediaEntity != null)
                        {
                            tmcContext.DeleteObject(listingMediaEntity);
                            tmcContext.DeleteObject(fileEntity);
                            tmcContext.SaveChanges();
                            retVal = fileEntity.ServerFileName;//todo check for null
                        }
                    }
                    trans.Complete();
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException("Error while deleting listing media.", ex);
            }
            return retVal;
        }