This commit is contained in:
@@ -221,7 +221,23 @@ namespace AyaNova.Biz
|
||||
|
||||
//Other job handlers here...
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//DUPLICATE ATTACHMENTS TO NEW OBJECT
|
||||
//
|
||||
internal static async Task DuplicateAttachments(AyaTypeId aSource, AyaTypeId aDest, AyContext ct)
|
||||
{
|
||||
var sources = await ct.FileAttachment.AsNoTracking()
|
||||
.Where(z => z.AttachToAType == aSource.AType && z.AttachToObjectId == aSource.ObjectId)
|
||||
.ToListAsync();
|
||||
if (sources.Count > 0)
|
||||
{
|
||||
foreach (var src in sources)
|
||||
{
|
||||
ct.FileAttachment.Add(new FileAttachment { AttachToObjectId = aDest.ObjectId, AttachToAType = aDest.AType, StoredFileName = src.StoredFileName, DisplayFileName = src.DisplayFileName, ContentType = src.ContentType, LastModified = src.LastModified, Notes = src.Notes, Exists = src.Exists, Size = src.Size });
|
||||
}
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace AyaNova.Biz
|
||||
if (newObject.GenCopyAttachmentsFrom !=null && !newObject.GenCopyAttachmentsFrom.IsEmpty)
|
||||
{
|
||||
//copy attachment from existing object
|
||||
|
||||
await AttachmentBiz.DuplicateAttachments(newObject.GenCopyAttachmentsFrom,new AyaTypeId(AyaType.WorkOrder,newObject.Id),ct);
|
||||
newObject.GenCopyAttachmentsFrom=null;//so it doesn't get returned
|
||||
}
|
||||
return newObject;
|
||||
|
||||
Reference in New Issue
Block a user