示例#1
0
        public DownloadAttachmentResponse DownloadAttachment(DownloadAttachmentRequest request)
        {
            // Create unit of work
            IUnitOfWork uow = new UnitOfWork(request.UserID);

            // Create repository
            Repository <Attachment>     attachmentRepository     = new Repository <Attachment>(uow.ObjectContext, request.UserID, request.UserID, "", "");     // currentUser, user, appID, overrideID);
            Repository <AttachmentData> attachmentdataRepository = new Repository <AttachmentData>(uow.ObjectContext, request.UserID, request.UserID, "", ""); // currentUser, user, appID, overrideID);

            //Create ExceptionManager
            IExceptionManager exceptionManager = new ExceptionManager();

            // Call overload with injected objects
            return(DownloadAttachment(attachmentRepository, attachmentdataRepository, uow, exceptionManager, request));
        }
示例#2
0
        /// <summary>
        /// DownloadAgreementDocument
        /// </summary>
        /// <param name="request">DownloadAgreementDocumentRequest information</param>
        public DownloadAttachmentResponse DownloadAttachment(IRepository <Attachment> attachmentRepository, IRepository <AttachmentData> attachmentDataRepository, IUnitOfWork uow,
                                                             IExceptionManager exceptionManager, DownloadAttachmentRequest request)
        {
            #region Parameter validation

            if (null == request)
            {
                throw new ArgumentOutOfRangeException("request");
            }
            if (null == attachmentRepository)
            {
                throw new ArgumentOutOfRangeException("dataRepository");
            }
            if (null == uow)
            {
                throw new ArgumentOutOfRangeException("uow");
            }

            #endregion


            DownloadAttachmentResponse ReturnValue = new DownloadAttachmentResponse();
            try
            {
                #region Parameter validation

                if (null == request)
                {
                    throw new ArgumentOutOfRangeException("request");
                }
                if (null == attachmentRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }

                #endregion
                using (uow)
                {
                    bool HasError = false;

                    // Create empty message list
                    List <string> Messages = new List <string>();

                    // Call business method
                    ReturnValue.DocumentBody = AttachmentComponent.DownloadAttachment(request.AttachmentCode, attachmentRepository);
                    //                               out Messages);


                    // Return success/failure indicator
                    ReturnValue.Result = HasError;
                }
            }
            catch (Exception e)
            {
                // If any exceptions occur, convert them to fault contract
                exceptionManager.ShieldException(e);
            }

            return(ReturnValue);
        }