コード例 #1
0
        public async Task <GetAttachmentForEditOutput> GetAttachmentForEdit(EntityDto input)
        {
            var attachment = await _attachmentRepository.FirstOrDefaultAsync(input.Id);

            var output = new GetAttachmentForEditOutput {
                Attachment = ObjectMapper.Map <CreateOrEditAttachmentDto>(attachment)
            };

            if (output.Attachment.AssetId != null)
            {
                var _lookupAsset = await _lookup_assetRepository.FirstOrDefaultAsync((int)output.Attachment.AssetId);

                output.AssetReference = _lookupAsset.Reference.ToString();
            }

            if (output.Attachment.IncidentId != null)
            {
                var _lookupIncident = await _lookup_incidentRepository.FirstOrDefaultAsync((int)output.Attachment.IncidentId);

                output.IncidentDescription = _lookupIncident.Description.ToString();
            }

            if (output.Attachment.LeaseAgreementId != null)
            {
                var _lookupLeaseAgreement = await _lookup_leaseAgreementRepository.FirstOrDefaultAsync((int)output.Attachment.LeaseAgreementId);

                output.LeaseAgreementReference = _lookupLeaseAgreement.Reference.ToString();
            }

            if (output.Attachment.QuotationId != null)
            {
                var _lookupQuotation = await _lookup_quotationRepository.FirstOrDefaultAsync((int)output.Attachment.QuotationId);

                output.QuotationTitle = _lookupQuotation.Title.ToString();
            }

            if (output.Attachment.SupportContractId != null)
            {
                var _lookupSupportContract = await _lookup_supportContractRepository.FirstOrDefaultAsync((int)output.Attachment.SupportContractId);

                output.SupportContractTitle = _lookupSupportContract.Title.ToString();
            }

            if (output.Attachment.WorkOrderId != null)
            {
                var _lookupWorkOrder = await _lookup_workOrderRepository.FirstOrDefaultAsync((int)output.Attachment.WorkOrderId);

                output.WorkOrderSubject = _lookupWorkOrder.Subject.ToString();
            }

            if (output.Attachment.CustomerInvoiceId != null)
            {
                var _lookupCustomerInvoice = await _lookup_customerInvoiceRepository.FirstOrDefaultAsync((int)output.Attachment.CustomerInvoiceId);

                output.CustomerInvoiceDescription = _lookupCustomerInvoice.Description.ToString();
            }

            return(output);
        }
コード例 #2
0
        /// <summary>
        /// 导出Attachment为excel表
        /// </summary>
        /// <returns></returns>
        //public async Task<FileDto> GetAttachmentsToExcel(){
        //var users = await UserManager.Users.ToListAsync();
        //var userListDtos = ObjectMapper.Map<List<UserListDto>>(users);
        //await FillRoleNames(userListDtos);
        //return _userListExcelExporter.ExportToFile(userListDtos);
        //}
        /// <summary>
        /// MPA版本才会用到的方法
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <GetAttachmentForEditOutput> GetAttachmentForEdit(NullableIdDto <int> input)
        {
            var output = new GetAttachmentForEditOutput();
            AttachmentEditDto attachmentEditDto;

            if (input.Id.HasValue)
            {
                var entity = await _attachmentRepository.GetAsync(input.Id.Value);

                attachmentEditDto = entity.MapTo <AttachmentEditDto>();

                //attachmentEditDto = ObjectMapper.Map<List <attachmentEditDto>>(entity);
            }
            else
            {
                attachmentEditDto = new AttachmentEditDto();
            }

            output.Attachment = attachmentEditDto;
            return(output);
        }