/// <summary>
        /// Find attachments that are not in the file system based on the application Id
        /// </summary>
        /// <param name="application">Application Object</param>
        /// <returns>List of attachments not exist in the file system</returns>
        public List <VerifyAttachmentViewModel> FindAllApplicationAttachmentsNotExistInFileSystem(ApplicationSubmission application)
        {
            List <VerifyAttachmentViewModel> attachmentNotExists = new List <VerifyAttachmentViewModel>();
            var allAttachments = _attachmentService.GetApplicationAttachments(ref application);

            foreach (var attachment in allAttachments)
            {
                if (attachment.Value != null)
                {
                    // Remove attachment Id from the DB
                    // Notify aplication attachment does not exist
                    using (var outMemoryStream = new MemoryStream())
                    {
                        try
                        {
                            // Check if the attachment exist in the file system
                            _attachmentService.DownloadAttachment(outMemoryStream, application.Id, new Guid(attachment.Value.Id));
                        }
                        catch
                        {
                            // Attachment does not exist in the file system
                            attachmentNotExists.Add(new VerifyAttachmentViewModel()
                            {
                                AttachmentId = attachment.Value.Id, AttachmentName = attachment.Value.OriginalFileName
                            });
                            // Remove attachment from datadase
                            _attachmentService.DeleteAttachement(application.Id, new Guid(attachment.Value.Id));
                        }
                    }
                }
            }
            return(attachmentNotExists);
        }
        public IHttpActionResult Delete(string ApplicationId, Guid fileId)
        {
            AccountController account = new AccountController(_employerService, _organizationService, _identityService);

            account.UserManager = UserManager;
            var userInfo = account.GetUserInfo();
            // make sure user has rights to the Id
            var hasPermission = _identityService.HasSavePermission(userInfo, ApplicationId);

            if (!hasPermission)
            {
                Unauthorized("Unauthorized");
            }

            try
            {
                _attachmentService.DeleteAttachement(ApplicationId, fileId);
            }
            catch (ObjectNotFoundException)
            {
                NotFound("Not found");
            }

            return(Ok());
        }
Пример #3
0
        public IHttpActionResult Delete(string EIN, Guid fileId)
        {
            // make sure user has rights to the EIN
            var hasEINClaim = _identityService.UserHasEINClaim(User, EIN);

            if (!hasEINClaim)
            {
                Unauthorized("Unauthorized");
            }

            try
            {
                _attachmentService.DeleteAttachement(EIN, fileId);
            }
            catch (ObjectNotFoundException)
            {
                NotFound("Not found");
            }

            return(Ok());
        }