и использовать примерно так:
namespace MT.api.Controllers.Tbl
{
[Route("test/[controller]")]
[ApiController]
public class ATemp_Sleeveboards_Controller : ControllerBase
{
private readonly MessageServiceLayer MessageServiceLayer;
private MessageServiceLayerBuilder MessageServiceLayerBuilder;
public ATemp_Sleeveboards_Controller(MessageServiceLayer messageServiceLayer, MessageServiceLayerBuilder messageServiceLayerBuilder)
{
MessageServiceLayer = messageServiceLayer;
MessageServiceLayerBuilder = messageServiceLayerBuilder;
}
[HttpGet(Name = "GetUserNames")]
public async Task<MessageServiceLayerBuilder> getUserNameOfSleeveBoard(Tbl_Sleeve_Board param)
{
return await MessageServiceLayerBuilder.WithObjectSleeveBoard(param);
}
}
}
public class MessageServiceLayer
{
private readonly MissionDBContext _context;
private readonly IWordsFilter _wordsFilter;
private readonly IHttpContextURL _httpContextURL;
#region Property
private readonly IFileService _fileService;
public static IWebHostEnvironment _webHostEnvironment;
#endregion
private Tbl_Sleeve_Board ?obj;
private Tbl_Member ?v;
private Tbl_Master_Board ?m;
public MessageServiceLayer(MissionDBContext context, IWordsFilter wordsFilter, IHttpContextURL httpContextUrl, IFileService fileService, Tbl_Sleeve_Board obj, Tbl_Member v, Tbl_Master_Board m)
{
_context = context;
_wordsFilter = wordsFilter;
_httpContextURL = httpContextUrl;
_fileService = fileService;
this.obj = obj;
this.v = v;
this.m = m;
}
}
public class MessageServiceLayerBuilder
{
private readonly MissionDBContext _context;
private readonly IWordsFilter _wordsFilter;
private readonly IHttpContextURL _httpContextUrl;
private readonly IFileService _fileService;
private Tbl_Sleeve_Board ?serviceSleeveBoard { get; set; }
private Tbl_Member ?serviceTbl_Member { get; set; }
private Tbl_Master_Board ?service_MasterBoard { get; set; }
public MessageServiceLayerBuilder(MissionDBContext context, IWordsFilter wordsFilter, IHttpContextURL httpContextUrl, IFileService fileService)
{
_context = context;
_wordsFilter = wordsFilter;
_httpContextUrl = httpContextUrl;
_fileService = fileService;
}
public async Task<MessageServiceLayerBuilder> WithObjectSleeveBoard(Tbl_Sleeve_Board obj)
{
serviceSleeveBoard = await _context.Tbl_Sleeve_Board.FirstOrDefaultAsync(x => x.UsedCode == obj.UsedCode && x.Idx_Board
== obj.Idx_Board && x.Encode_Board == Security.EncryptSHA512(obj.Encode_Board).ToString());;
return this;
}
public async Task<MessageServiceLayerBuilder> WithObjectTblMember(Tbl_Member v)
{
serviceTbl_Member = await _context.Tbl_Member.FirstOrDefaultAsync(x => x.UsedCode.ToString() == serviceSleeveBoard.UsedCode);
return this;
}
public async Task<MessageServiceLayerBuilder> WithMasterBoard(Tbl_Master_Board m)
{
service_MasterBoard = await _context.Tbl_Master_Board.FirstOrDefaultAsync(x => x.UsedCode == serviceSleeveBoard.Encode_Board);
return this;
}
public async Task<MessageServiceLayer> Build()
{
return new MessageServiceLayer(_context, _wordsFilter, _httpContextUrl, _fileService, serviceSleeveBoard, serviceTbl_Member, service_MasterBoard);
}
}
Для начала бы код кидать через пастебин хотя бы
а всё понял ошибочка с моей стороны)
Обсуждают сегодня