Exemple #1
0
        public ProductComplianceModel MapToModel(ProductCompliance item)
        {
            if (item == null)
            {
                return(null);
            }
            else
            {
                var newItem = Mapper.Map <ProductCompliance, ProductComplianceModel>(item);
                if (item.LOVItem_ComplianceCategory != null)
                {
                    newItem.ComplianceCategoryText = item.LOVItem_ComplianceCategory.ItemText;
                }
                if (item.LOVItem_Market != null)
                {
                    newItem.MarketNameText = item.LOVItem_Market.ItemText;
                }

                // Add the attachments
                foreach (var attachment in item.ProductComplianceAttachments)
                {
                    var newAttachment = new ProductComplianceAttachmentModel {
                        Id = attachment.Id,
                        ProductComplianceId = attachment.ProductComplianceId,
                        MediaId             = attachment.MediaId,
                        FileName            = attachment.Medium.FileName,
                        QualName            = MediaServices.GetMediaFolder(-1, true) + attachment.Medium.FolderName + attachment.Medium.FileName
                    };
                    newItem.Attachments.Add(newAttachment);

                    if (!string.IsNullOrEmpty(newItem.AttachmentHtml))
                    {
                        newItem.AttachmentHtml += "<br/>";
                    }
                    newItem.AttachmentHtml += $"<a href=\"{newAttachment.QualName}\" target=\"_new\">{newAttachment.FileName}</a>";
                }
                return(newItem);
            }
        }
Exemple #2
0
 public Error DeleteProductComplianceAttachment(ProductComplianceAttachmentModel attachment)
 {
     return(deleteProductComplianceAttachment(attachment.Id));
 }