首页 > 解决方案 > 将函数从一个服务传递和调用到另一个服务

问题描述

我写了一个函数来获取和更新我需要的东西。

public async Task<bool> UpdateWellFile(IEnumerable<AttachedFileListView> files, string wellId)
    {
        var updateFiles = await _attachedFileRepo.GetAllQueryable().Where(af => af.WellId == wellId).ToListAsync();

        
        if (files == null)
        {
            throw new ServiceException("File Not Found.");
        }
       foreach(var file in files)
        {
            var updateFile = updateFiles.SingleOrDefault(af => af.Id == file.Id);
           
            updateFile.Category = file.Category;
            _attachedFileRepo.Update(updateFile);

        }
        await _attachedFileRepo.CommitAsync();

        return true;
       
    }

这是在我的 AttachedFile 界面中

 public interface IAttachedFileService
{
    Task<IEnumerable<AttachedFileListView>> GetWellAttachedFiles(string wellId);
    Task<string> SaveFile(IFormFile file, string wellId, string userId);
    Task<IEnumerable<string>> SaveFiles (IEnumerable<IFormFile> files, string wellId, string userId);
    Task<bool> UpdateWellFile(IEnumerable<AttachedFileListView> files, string wellId);
    Task<AttachedFile> GetFile(string fileId);
    Task<string> DeleteFile(string fileId);
}

现在我需要将这个 updateWellFile 函数传递给 WellService 并调用它,所以我将它添加到服务中,但它抛出了这个错误

服务好

这是很好的服务,我添加了“accountservice”,所以我不确定它还需要什么

在此处输入图像描述

标签: c#entity-framework-core

解决方案


推荐阅读