wxd 2 years ago
parent
commit
d0f1326b05
  1. 44
      src/Shentun.Peis.Application/GuideTypes/GuideTypeAppService.cs
  2. 2
      src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
  3. 42
      test/Shentun.Peis.Application.Tests/ApiWorkTest.cs
  4. 2
      test/Shentun.Peis.Domain.Tests/ItemManagerTest.cs

44
src/Shentun.Peis.Application/GuideTypes/GuideTypeAppService.cs

@ -5,6 +5,7 @@ using Shentun.Peis.Books;
using Shentun.Peis.GuidTypes;
using Shentun.Peis.HelperDto;
using Shentun.Peis.Models;
using Shentun.Peis.Sexs;
using Shentun.Peis.Units;
using System;
using System.Collections;
@ -37,15 +38,21 @@ namespace Shentun.Peis.GuideTypes
UpdateGuideTypeDto>
{
private readonly IRepository<IdentityUser, Guid> _userRepository;
private readonly IRepository<Sex> _sexRepository;
private readonly GuideTypeManager _manager;
private readonly SexManager _sexManager;
public GuideTypeAppService(
IRepository<GuideType, Guid> repository,
IRepository<IdentityUser, Guid> userRepository,
GuideTypeManager manager)
GuideTypeManager manager,
SexManager sexManager,
IRepository<Sex> sexRepository = null)
: base(repository)
{
this._userRepository = userRepository;
_manager = manager;
_sexManager = sexManager;
_sexRepository = sexRepository;
}
@ -162,7 +169,7 @@ namespace Shentun.Peis.GuideTypes
}
/// <summary>
/// 修改排序 置顶,置底
@ -187,5 +194,38 @@ namespace Shentun.Peis.GuideTypes
{
await _manager.UpdateSortManyAsync(input);
}
public async Task TestApi()
{
var guideTypeEntity = await CreateAsync(new CreateGuideTypeDto
{
DisplayName = "测试指引类别0322",
});
var entity = await Repository.GetAsync(guideTypeEntity.Id);
var sourceEntity = new GuideType
{
DisplayName = "测试指引类别0323"
};
await _manager.UpdateAsync(sourceEntity, entity);
var sexEntity = await _sexRepository.GetAsync(m => m.Id == 'U');
var sexSourceEntity = new Sex
{
DisplayName = "未知1"
};
await _sexManager.UpdateAsync(sexSourceEntity, sexEntity);
throw new UserFriendlyException("eee");
}
}
}

2
src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs

@ -1288,7 +1288,7 @@ namespace Shentun.Peis.PatientRegisters
char? MaritalStatusId = null;
if (!DataHelper.IsNullOrEmpty(input.MaritalStatusName))
{
var MaritalStatusEnt = await _maritalStatusRepositoryFirstOrDefaultAsync(m => m.DisplayName == input.MaritalStatusName);
var MaritalStatusEnt = await _maritalStatusRepository.FirstOrDefaultAsync(m => m.DisplayName == input.MaritalStatusName);
if (MaritalStatusEnt != null)
{
MaritalStatusId = MaritalStatusEnt.Id;

42
test/Shentun.Peis.Application.Tests/ApiWorkTest.cs

@ -0,0 +1,42 @@
using Shentun.Peis.GuideTypes;
using Shentun.Peis.Models;
using Shentun.Peis.Sexs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Volo.Abp.Uow;
using Xunit;
using Xunit.Abstractions;
namespace Shentun.Peis
{
public class ApiWorkTest : PeisApplicationTestBase
{
private readonly GuideTypeAppService _appService;
private readonly ITestOutputHelper _output;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public ApiWorkTest(ITestOutputHelper testOutputHelper)
{
_output = testOutputHelper;
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_appService = GetRequiredService<GuideTypeAppService>();
}
[Fact]
//[UnitOfWork]
public async Task TestApi()
{
using (var aaa = _unitOfWorkManager.Begin(true, true))
{
await _appService.TestApi();
}
}
}
}

2
test/Shentun.Peis.Domain.Tests/ItemManagerTest.cs

@ -33,7 +33,7 @@ namespace Shentun.Peis
}
[Fact]
[UnitOfWork]
public async void CheckAndDeleteAsyncTest()
{

Loading…
Cancel
Save