fix 餐次段编辑赋值

This commit is contained in:
2024-04-09 17:36:28 +08:00
parent 2d724500e0
commit d257df697f
3 changed files with 18 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ public class BusinessShiftsController : ControllerBase
}
/// <summary>
/// 餐次分页
/// 餐别分页
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
@@ -35,7 +35,7 @@ public class BusinessShiftsController : ControllerBase
}
/// <summary>
/// 餐次列表
/// 餐别列表
/// </summary>
/// <returns></returns>
[HttpGet("list")]
@@ -45,7 +45,7 @@ public class BusinessShiftsController : ControllerBase
}
/// <summary>
/// 餐次保存
/// 餐别保存
/// </summary>
/// <param name="request"></param>
/// <returns></returns>

View File

@@ -9,7 +9,7 @@ public class BusinessPlaceShiftSaveMealShiftRequest : IValidatableObject
public long? Id { get; set; }
/// <summary>
/// 餐次Code
/// 餐别Code
/// </summary>
public Guid ShiftCode { get; set; }
@@ -32,6 +32,16 @@ public class BusinessPlaceShiftSaveMealShiftRequest : IValidatableObject
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (TimePeriod == null)
{
yield return new ValidationResult("时间段配置错误", new[] { nameof(TimePeriod) });
}
if (TimePeriod?.Start == null || TimePeriod?.End == null)
{
yield return new ValidationResult("时间段配置错误", new[] { nameof(TimePeriod) });
}
if (TimePeriod.Start == TimePeriod.End)
{
yield return new ValidationResult("时间段设置区间有误,开始时段不能等于结束时段.", new[] { nameof(TimePeriod) });

View File

@@ -82,7 +82,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
else
{
var entity = await _dbContext.Queryable<BusinessShiftEntity>().FirstAsync(x => x.Id == request.Id);
entity.ThrowIfNull("餐次不存在");
entity.ThrowIfNull("餐别不存在");
request.Adapt(entity);
await _dbContext.UpdateAsync(entity);
@@ -115,6 +115,9 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
var entity = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>().FirstAsync(x => x.Id == request.Id);
entity.ThrowIfNull("餐次段不存在");
entity.Start = request.TimePeriod.Start.Value;
entity.End = request.TimePeriod.End.Value;
request.Adapt(entity);
await _dbContext.UpdateAsync(entity);
}