diff --git a/src/Shentun.Peis.Application.Contracts/Sexs/UpdateSexDto.cs b/src/Shentun.Peis.Application.Contracts/Sexs/UpdateSexDto.cs
index 4a8428c6..a5a09edc 100644
--- a/src/Shentun.Peis.Application.Contracts/Sexs/UpdateSexDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/Sexs/UpdateSexDto.cs
@@ -11,8 +11,8 @@ namespace Shentun.Peis.Sexs
{
[Required]
public string DisplayName { get; set; }
- //[Required]
- //public string SimpleCode { get; set; }
+ [Required]
+ public string SimpleCode { get; set; }
}
diff --git a/src/Shentun.Peis.Application/Sexs/SexAppService.cs b/src/Shentun.Peis.Application/Sexs/SexAppService.cs
index 6946e81a..fe550d4b 100644
--- a/src/Shentun.Peis.Application/Sexs/SexAppService.cs
+++ b/src/Shentun.Peis.Application/Sexs/SexAppService.cs
@@ -56,27 +56,22 @@ namespace Shentun.Peis.Sexs
/// 修改参数
///
[HttpPost]
- public async Task UpdateAsync(char Id, UpdateSexDto input)
+ public async Task UpdateAsync(char Id, UpdateSexDto input)
{
var ent = await _repository.GetAsync(m => m.Id == Id);
- if (ent != null)
- {
- if (DateHelper.IsNullOrEmpty(input.DisplayName))
- throw new UserFriendlyException("名称不能为空");
+ if (DateHelper.IsNullOrEmpty(input.DisplayName))
+ throw new UserFriendlyException("名称不能为空");
- ent.DisplayName = input.DisplayName;
- ent.SimpleCode = LanguageConverter.GetPYSimpleCode(input.DisplayName);
+ ent.DisplayName = input.DisplayName;
+ ent.SimpleCode = input.SimpleCode;
+
+ var newent = await _repository.UpdateAsync(ent);
+
+ return ObjectMapper.Map(newent);
- var newent = await _repository.UpdateAsync(ent);
- return ObjectMapper.Map(newent);
- }
- else
- {
- return ObjectMapper.Map(ent);
- }
}
diff --git a/src/Shentun.Peis.Domain/MedicalReportTypes/MedicalReportTypeManager.cs b/src/Shentun.Peis.Domain/MedicalReportTypes/MedicalReportTypeManager.cs
index acf8361a..fb85bf28 100644
--- a/src/Shentun.Peis.Domain/MedicalReportTypes/MedicalReportTypeManager.cs
+++ b/src/Shentun.Peis.Domain/MedicalReportTypes/MedicalReportTypeManager.cs
@@ -36,6 +36,7 @@ namespace Shentun.Peis.MedicalReportTypes
{
Check.NotNullOrWhiteSpace(entity.DisplayName, nameof(entity.DisplayName));
await EntityHelper.CheckSameName(_repository, entity.DisplayName);
+
return new MedicalReportType(
GuidGenerator.Create()
)
diff --git a/test/Shentun.Peis.Application.Tests/SexAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/SexAppServiceTest.cs
new file mode 100644
index 00000000..a3a15353
--- /dev/null
+++ b/test/Shentun.Peis.Application.Tests/SexAppServiceTest.cs
@@ -0,0 +1,51 @@
+using Microsoft.EntityFrameworkCore;
+using Shentun.Peis.GuideTypes;
+using Shentun.Peis.Models;
+using Shentun.Peis.Sexs;
+using Shouldly;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Uow;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Shentun.Peis
+{
+ public class SexAppServiceTest:PeisApplicationTestBase
+ {
+ private readonly IRepository _repository;
+ private readonly SexAppService _appService;
+ private readonly ITestOutputHelper _output;
+ private readonly IUnitOfWorkManager _unitOfWorkManager;
+ public SexAppServiceTest(ITestOutputHelper testOutputHelper)
+ {
+ _output = testOutputHelper;
+ _unitOfWorkManager = GetRequiredService();
+ _repository = GetRequiredService>();
+ _appService = GetRequiredService();
+ }
+ [Fact]
+ public async Task UpdateAsync()
+ {
+ var dto = new UpdateSexDto() {
+ DisplayName = "未知",
+ SimpleCode = "A",
+ };
+ try
+ {
+ await _appService.UpdateAsync('U', dto);
+ }
+ catch (Exception ex)
+ {
+ _output.WriteLine(ex.ToString());
+ }
+
+ }
+
+ }
+}