示例#1
0
        public bool RemoveImage(string imageName, ImagesType type)
        {
            try
            {
                var path      = "";
                var thumbPath = "";

                switch (type)
                {
                case ImagesType.Anouncement:
                    path      = AnouncementImagesPath + imageName;
                    thumbPath = ThumbAnouncementImagesPath + imageName;
                    break;

                case ImagesType.Realty:
                    path      = RealtyImagesPath + imageName;
                    thumbPath = ThumbRealtyImagesPath + imageName;
                    break;
                }
                System.IO.File.Delete(path);
                System.IO.File.Delete(thumbPath);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#2
0
        public bool RemoveImage(string announcementId, string imageName, ImagesType type)
        {
            var id = Convert.ToInt32(announcementId);

            try
            {
                switch (type)
                {
                case ImagesType.Anouncement:
                    var announcement = _announcement.Read(id);
                    if (announcement == null)
                    {
                        throw new Exception();
                    }
                    _announcementImage.DeleteImage(id, imageName);
                    break;

                case ImagesType.Realty:
                    var realty = _realty.Read(id);
                    if (realty == null)
                    {
                        throw new Exception();
                    }
                    _realtyImage.DeleteImage(id, imageName);
                    break;
                }

                RemoveImage(imageName, type);
            }
            catch
            {
                return(false);
            }

            return(true);
        }