83 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using System.Threading.Tasks;
 | 
						|
 | 
						|
namespace BLL
 | 
						|
{
 | 
						|
    public static class PhotoService
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 根据主键返回一个照片信息
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="cnProfessionalCode">文件编号</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static Model.DataBase_Photo GetPhotoById(string photoId)
 | 
						|
        {
 | 
						|
            return Funs.DB.DataBase_Photo.FirstOrDefault(x => x.PhotoId == photoId);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 添加照片
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="Installation"></param>
 | 
						|
        public static void AddPhoto(Model.DataBase_Photo photo)
 | 
						|
        {
 | 
						|
            Model.DataBase_Photo newPhoto = new Model.DataBase_Photo();
 | 
						|
 | 
						|
            newPhoto.PhotoId = photo.PhotoId;
 | 
						|
            newPhoto.ProjectId = photo.ProjectId;
 | 
						|
            newPhoto.PhotoType = photo.PhotoType;
 | 
						|
            newPhoto.Date = photo.Date;
 | 
						|
            newPhoto.Place = photo.Place;
 | 
						|
            newPhoto.Person = photo.Person;
 | 
						|
            newPhoto.Subject = photo.Subject;
 | 
						|
            newPhoto.Background = photo.Background;
 | 
						|
            newPhoto.Photographer = photo.Photographer;
 | 
						|
            newPhoto.AttachUrl = photo.AttachUrl;
 | 
						|
 | 
						|
            Funs.DB.DataBase_Photo.InsertOnSubmit(newPhoto);
 | 
						|
            Funs.DB.SubmitChanges();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 修改照片
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="photo"></param>
 | 
						|
        public static void UpdatePhoto(Model.DataBase_Photo photo)
 | 
						|
        {
 | 
						|
            Model.DataBase_Photo newPhoto = Funs.DB.DataBase_Photo.FirstOrDefault(e => e.PhotoId == photo.PhotoId);
 | 
						|
            if (newPhoto != null)
 | 
						|
            {
 | 
						|
                newPhoto.Date = photo.Date;
 | 
						|
                newPhoto.Place = photo.Place;
 | 
						|
                newPhoto.Person = photo.Person;
 | 
						|
                newPhoto.Subject = photo.Subject;
 | 
						|
                newPhoto.Background = photo.Background;
 | 
						|
                newPhoto.Photographer = photo.Photographer;
 | 
						|
                newPhoto.AttachUrl = photo.AttachUrl;
 | 
						|
                Funs.DB.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据一个照片信息
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="breakdownCode"></param>
 | 
						|
        public static void DeletePhotoById(string photoId)
 | 
						|
        {
 | 
						|
            Model.DataBase_Photo photo = Funs.DB.DataBase_Photo.FirstOrDefault(e => e.PhotoId == photoId);
 | 
						|
            if (photo != null)
 | 
						|
            {
 | 
						|
                if (!string.IsNullOrEmpty(photo.AttachUrl))
 | 
						|
                {
 | 
						|
                    BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, photo.AttachUrl);//删除附件
 | 
						|
                }
 | 
						|
                Funs.DB.DataBase_Photo.DeleteOnSubmit(photo);
 | 
						|
                Funs.DB.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |