예제 #1
0
        public void Delete(int id)
        {
            var photo = new PhotoDa(databasecontext);
            if (id > 0)
            {
                var currentPhoto = GetById(id);

                //delete images
                ImageFiles.DeleteImage(currentPhoto.FilePath);
                ImageFiles.DeleteImage(currentPhoto.IconPath);
                ImageFiles.DeleteImage(currentPhoto.PreviewPath);
                ImageFiles.DeleteImage(currentPhoto.ThumbPath);

                //delete record from database
                photo.Delete(currentPhoto);
            }
        }
예제 #2
0
        public Photo Save(int id, int OwnerId, PhotoType PhotoType, string FilePath, string PreviewPath, string ThumbPath, string IconPath)
        {
            var photo = id > 0 ? GetById(id) : new Photo();

            photo.ArticleId = PhotoType == PhotoType.Article ? OwnerId : 0;
            photo.WorkId = PhotoType == PhotoType.Work ? OwnerId : 0;
            photo.PhotoType = (int)PhotoType;
            photo.FilePath = FilePath;
            photo.PreviewPath = PreviewPath;
            photo.ThumbPath = ThumbPath;
            photo.IconPath = IconPath;

            var photoDa = new PhotoDa(databasecontext);

            //if new
            if (id < 1) photo = photoDa.Add(photo);
            //update
            else photo = photoDa.Update(photo);

            return photo;
        }