public virtual void DeleteTempAttachment(long id) { ContentAttachmentTemp at = ContentAttachmentTemp.findById(id); if (at == null) { return; } at.delete(); Img.DeleteImgAndThumb(at.FileUrl); }
public virtual void CreateByTemp(String ids, ContentPost post) { int[] arrIds = cvt.ToIntArray(ids); if (arrIds.Length == 0) { return; } int attachmentCount = 0; foreach (int id in arrIds) { ContentAttachmentTemp at = ContentAttachmentTemp.findById(id); if (at == null) { continue; } ContentAttachment a = new ContentAttachment(); a.AppId = at.AppId; a.Guid = at.Guid; a.FileSize = at.FileSize; a.Type = at.Type; a.Name = at.Name; a.Description = at.Description; a.PostId = post.Id; a.OwnerId = post.OwnerId; a.OwnerType = post.OwnerType; a.OwnerUrl = post.OwnerUrl; a.Creator = post.Creator; a.CreatorUrl = post.CreatorUrl; a.insert(); at.delete(); attachmentCount++; } post.Attachments = attachmentCount; post.update("Attachments"); }