修改一版
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using IRaCIS.Core.Domain.Share.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,11 +7,49 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
{
|
||||
public class ReadingPeriodSetAddOrEdit : ReadingPeriodSet
|
||||
public class ReadingPeriodSetAddOrEdit
|
||||
{
|
||||
public new Guid? Id { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 项目ID
|
||||
/// </summary>
|
||||
public Guid? TrialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 阅片期名称
|
||||
/// </summary>
|
||||
public string ReadingPeriodName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 阅片范围
|
||||
/// </summary>
|
||||
public ReadingScopeEnum? ReadingScope { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 截止日期
|
||||
/// </summary>
|
||||
public DateTime ExpirationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 截止访视
|
||||
/// </summary>
|
||||
public decimal? ExpirationVisit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访视计划ID
|
||||
/// </summary>
|
||||
public Guid? VisitStageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否生效
|
||||
/// </summary>
|
||||
public int? IsTakeEffect { get; set; }
|
||||
|
||||
|
||||
public List<Guid> SiteIds { get; set; } = new List<Guid>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class ReadingPeriodSetView : ReadingPeriodSet
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace IRaCIS.Application.Services
|
||||
x.FileName,
|
||||
x.UploadType,
|
||||
x.Id,
|
||||
|
||||
}).ToListAsync();
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,31 @@ namespace IRaCIS.Application.Services
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateReadingPeriodSet(ReadingPeriodSetAddOrEdit addOrEditReadingPeriodSet)
|
||||
{
|
||||
var entity = await _repository.InsertOrUpdateAsync<ReadingPeriodSet, ReadingPeriodSetAddOrEdit>(addOrEditReadingPeriodSet, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
if (addOrEditReadingPeriodSet.Id == null)
|
||||
{
|
||||
var entity = _mapper.Map<ReadingPeriodSet>(addOrEditReadingPeriodSet);
|
||||
entity.ReadingPeriodSites = addOrEditReadingPeriodSet.SiteIds.Select(x => new ReadingPeriodSite()
|
||||
{
|
||||
ReadingPeriodSetId = entity.Id,
|
||||
SiteId = x,
|
||||
}).ToList();
|
||||
|
||||
await _readingPeriodSetRepository.AddAsync(entity, true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = (await _readingPeriodSetRepository.Where(t => t.Id == addOrEditReadingPeriodSet.Id, true).Include(t => t.ReadingPeriodSites).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
_mapper.Map(addOrEditReadingPeriodSet, entity);
|
||||
entity.ReadingPeriodSites = addOrEditReadingPeriodSet.SiteIds.Select(x => new ReadingPeriodSite()
|
||||
{
|
||||
ReadingPeriodSetId = entity.Id,
|
||||
SiteId = x,
|
||||
}).ToList();
|
||||
var success = await _readingPeriodSetRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
public ReadingConfig()
|
||||
{
|
||||
CreateMap<ReadingPeriodSet, ReadingPeriodSetAddOrEdit>().ReverseMap();
|
||||
CreateMap<ReadingPeriodSetAddOrEdit, ReadingPeriodSet>();
|
||||
|
||||
|
||||
CreateMap<ReadingPeriodSet, ReadingPeriodSetView>();
|
||||
|
||||
@@ -23,6 +24,11 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
CreateMap<PreviousPDF, PreviousPDFView>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user