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