private PhotoAlbum getDefaultAlbum( int ownerId ) { PhotoAlbum album = new PhotoAlbum(); album.Name = alang.get( typeof(PhotoApp), "defaultAlbum" ); album.OwnerId = ownerId; return album; }
public static int getDataCount( PhotoAlbum album ) { if (album.DataCount > 0) return album.DataCount; int count = PhotoPost.find( "AppId=" + album.AppId + " and PhotoAlbum.Id=" + album.Id ).count(); album.DataCount = count; album.update( "DataCount" ); return count; }
private static PhotoAlbum createUserAlbum( User creator, PhotoApp app ) { PhotoAlbum album = new PhotoAlbum(); album.Name = "我的图片"; album.OwnerId = creator.Id; album.OwnerUrl = creator.Url; album.OwnerId = creator.Id; album.OwnerUrl = creator.Url; album.AppId = app.Id; album.insert(); return album; }
public static string getCover( PhotoAlbum album ) { if (strUtil.HasText( album.Logo )) return sys.Path.GetPhotoThumb( album.Logo, "sx" ); PhotoPost photo = PhotoPost.find( "AppId=" + album.AppId + " and PhotoAlbum.Id=" + album.Id ).first(); if (photo != null) { album.Logo = photo.DataUrl; album.update( "Logo" ); return photo.ImgThumbUrl; } return strUtil.Join( sys.Path.Img, "/m/album.jpg" ); }
public virtual Result Update( PhotoAlbum album ) { return db.update( album ); }
public virtual void Delete( PhotoAlbum album ) { db.updateBatch<PhotoPost>( "SaveStatus=" + SaveStatus.Delete, "CategoryId=" + album.Id ); db.delete( album ); }
//private PhotoAlbum GetDefaultAlbum( int userId ) { // return db.find<PhotoAlbum>( "IsDefault=1 and OwnerId=" + userId ).first(); //} public virtual Result Create( PhotoAlbum album ) { return db.insert( album ); }
private void setCategoryDropList() { List<PhotoAlbum> albumList = albumService.GetListByApp( ctx.app.Id ); PhotoAlbum album = new PhotoAlbum(); album.Id = -1; album.Name = alang( "moveToAlbum" ); List<PhotoAlbum> list = new List<PhotoAlbum>(); list.Add( album ); foreach (PhotoAlbum a in albumList) { list.Add( a ); } dropList( "adminDropCategoryList", list, "Name=Id", null ); }
private PhotoAlbum createDefaultAlbum( User user, int appId ) { PhotoAlbum album = new PhotoAlbum(); album.Name = alang.get( typeof( PhotoApp ), "defaultAlbum" ); album.IsDefault = 1; album.OwnerId = user.Id; album.OwnerUrl = user.Url; album.AppId = appId; db.insert( album ); return album; }
public virtual PhotoPost GetById( int id, int ownerId ) { PhotoPost post = GetById( id ); if (post == null) return null; if (post.OwnerId != ownerId) return null; PhotoAlbum album = new PhotoAlbum(); album.Id = 0; album.Name = alang.get( typeof( PhotoApp ), "defaultAlbum" ); if (post.PhotoAlbum == null) post.PhotoAlbum = album; return post; }
public static PhotoAlbum New( int albumId ) { PhotoAlbum album = new PhotoAlbum(); album.Id = albumId; return album; }
// album count private void updateCountAlbum( PhotoAlbum album ) { int count = db.count<PhotoPost>( "CategoryId=" + album.Id ); album.DataCount = count; db.update( album, "DataCount" ); }
private PhotoPost newPost( String photoName, String imgPath, int albumId, int systemCategoryId ) { PhotoAlbum album = new PhotoAlbum(); album.Id = albumId; PhotoPost photo = new PhotoPost(); photo.AppId = ctx.app.Id; photo.SysCategoryId = systemCategoryId; photo.PhotoAlbum = album; photo.Creator = (User)ctx.viewer.obj; photo.CreatorUrl = ctx.viewer.obj.Url; photo.OwnerId = ctx.owner.Id; photo.OwnerUrl = ctx.owner.obj.Url; photo.OwnerType = ctx.owner.obj.GetType().FullName; photo.Title = photoName; photo.DataUrl = imgPath; photo.Ip = ctx.Ip; return photo; }
public void Update( int id ) { PhotoPost post = postService.GetById( id, ctx.owner.Id ); if (post == null) { echoRedirect( lang( "exDataNotFound" ) ); return; } PhotoAlbum album = new PhotoAlbum(); album.Id = ctx.PostInt( "PhotoAlbumId" ); post.SysCategoryId = ctx.PostInt( "SystemCategoryId" ); post.Title = ctx.Post( "Title" ); post.PhotoAlbum = album; post.Description = ctx.Post( "Description" ); if (post.SysCategoryId <= 0) errors.Add( alang( "exSysCategoryRequire" ) ); if (strUtil.IsNullOrEmpty( post.Title )) errors.Add( alang( "exPhotoName" ) ); if (ctx.HasErrors) { echoError(); return; } Result result = postService.Update( post ); if (result.IsValid) { TagService.SaveDataTag( post, ctx.Post( "TagList" ) ); echoToParentPart( lang( "opok" ), to( new MyController().My ) ); } else { echoError(); } }
private int getDataCount( PhotoAlbum album ) { int count = PhotoPost.find( "AppId=" + ctx.app.Id + " and PhotoAlbum.Id=" + album.Id ).count(); album.DataCount = count; if (album.DataCount != count) { album.update( "DataCount" ); } return count; }