forked from ddrilling/AsbCloudServer
Рефакторинг контроллеров
This commit is contained in:
parent
17454f762c
commit
84564c2a38
@ -571,10 +571,10 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
||||
//arrange
|
||||
const string fileName = "ProcessMapPlanDrillingValid.xlsx";
|
||||
var stream = Assembly.GetExecutingAssembly().GetFileCopyStream(fileName);
|
||||
|
||||
//act
|
||||
var streamPart = new StreamPart(stream, fileName, "application/octet-stream");
|
||||
var response = await client.Parse(Defaults.Wells[0].Id, new[] { streamPart });
|
||||
|
||||
//act
|
||||
var response = await client.Parse(Defaults.Wells[0].Id, streamPart);
|
||||
|
||||
//assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
@ -589,9 +589,8 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
||||
var dtoActual = row.Item;
|
||||
|
||||
Assert.True(row.IsValid);
|
||||
|
||||
var excludeProps = new[] { nameof(ProcessMapPlanDrillingDto.IdWell) };
|
||||
MatchHelper.Match(dto, dtoActual, excludeProps);
|
||||
|
||||
MatchHelper.Match(dto, dtoActual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -600,11 +599,12 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
||||
//arrange
|
||||
const string fileName = "ProcessMapPlanDrillingInvalid.xlsx";
|
||||
var stream = Assembly.GetExecutingAssembly().GetFileCopyStream(fileName);
|
||||
var streamPart = new StreamPart(stream, fileName, "application/octet-stream");
|
||||
|
||||
//act
|
||||
var streamPart = new StreamPart(stream, fileName, "application/octet-stream");
|
||||
var response = await client.Parse(Defaults.Wells[0].Id, new[] { streamPart });
|
||||
var response = await client.Parse(Defaults.Wells[0].Id, streamPart);
|
||||
|
||||
//assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
|
||||
var parserResult = response.Content;
|
||||
|
@ -30,11 +30,11 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
{
|
||||
private readonly IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository;
|
||||
private readonly IWellService wellService;
|
||||
private readonly ParserExcelService<TDto> parserService;
|
||||
private readonly ParserExcelService<TDto, WellRelatedParserRequest> parserService;
|
||||
|
||||
protected ProcessMapPlanBaseController(IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository,
|
||||
IWellService wellService,
|
||||
ParserExcelService<TDto> parserService)
|
||||
ParserExcelService<TDto, WellRelatedParserRequest> parserService)
|
||||
{
|
||||
this.repository = repository;
|
||||
this.wellService = wellService;
|
||||
@ -213,7 +213,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<ParserResultDto<TDto>>> Parse(int idWell,
|
||||
[Required] IFormFile file,
|
||||
[Required] IFormFile file,
|
||||
CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWell(idWell, token);
|
||||
@ -222,9 +222,8 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
|
||||
try
|
||||
{
|
||||
var dto = parserService.Parse(stream, IParserOptionsRequest.Empty());
|
||||
foreach (var item in dto.Item)
|
||||
item.Item.IdWell = idWell;
|
||||
var options = new WellRelatedParserRequest(idWell);
|
||||
var dto = parserService.Parse(stream, options);
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Requests.ParserOptions;
|
||||
using AsbCloudInfrastructure.Services.Parser;
|
||||
using AsbCloudInfrastructure.Services.Trajectory.Parser;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers.Trajectory
|
||||
{
|
||||
@ -25,11 +26,11 @@ namespace AsbCloudWebApi.Controllers.Trajectory
|
||||
public abstract class TrajectoryEditableController<TDto> : TrajectoryController<TDto>
|
||||
where TDto : TrajectoryGeoDto
|
||||
{
|
||||
private readonly ParserExcelService<TDto> parserService;
|
||||
private readonly TrajectoryParser<TDto> parserService;
|
||||
private readonly ITrajectoryEditableRepository<TDto> trajectoryRepository;
|
||||
|
||||
protected TrajectoryEditableController(IWellService wellService,
|
||||
ParserExcelService<TDto> parserService,
|
||||
TrajectoryParser<TDto> parserService,
|
||||
TrajectoryExportService<TDto> trajectoryExportService,
|
||||
ITrajectoryEditableRepository<TDto> trajectoryRepository)
|
||||
: base(wellService, trajectoryExportService, trajectoryRepository)
|
||||
@ -78,7 +79,9 @@ namespace AsbCloudWebApi.Controllers.Trajectory
|
||||
|
||||
try
|
||||
{
|
||||
var dto = parserService.Parse(stream, IParserOptionsRequest.Empty());
|
||||
var options = new WellRelatedParserRequest(idWell);
|
||||
var dto = parserService.Parse(stream, options);
|
||||
|
||||
return Ok(dto);
|
||||
}
|
||||
catch (FileFormatException ex)
|
||||
|
Loading…
Reference in New Issue
Block a user