diff --git a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs index 17f2805..263e4b7 100644 --- a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs +++ b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs @@ -191,10 +191,9 @@ namespace WebStarter.Controllers.BasicConfig StartTime = new TimeSpan(item.StartHour, item.StartMinute, item.StartSecond), EndTime = new TimeSpan(item.EndHour, item.EndMinute, item.EndSecond), Price = item.Price, - Type = item.Price + Type = item.Type }); } - return Result>.Success(elecPriceModelVersionDetailResps); } @@ -257,14 +256,6 @@ namespace WebStarter.Controllers.BasicConfig { Result.Fail("参数不能为空"); } - - List modelFromDbs = - await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); - if (modelFromDbs != null) - { - await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version); - } - List elecPriceModelVersionDetails = new List(); foreach (var item in model) { @@ -281,14 +272,19 @@ namespace WebStarter.Controllers.BasicConfig Type = item.Type }); } + if (!TimeListIfContains(elecPriceModelVersionDetails)) + { + return Result.Fail("时间区间重复请检查"); + } - if (TimeListIfContains(elecPriceModelVersionDetails)) + List modelFromDbs = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); + if (modelFromDbs != null) { - await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails); - return Result.Success(true); + await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version); } + await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails); + return Result.Success(true); - return Result.Fail("时间区间重复请检查"); } @@ -300,7 +296,7 @@ namespace WebStarter.Controllers.BasicConfig [ApiExplorerSettings(IgnoreApi = true)] public bool TimeListIfContains(List timePeriods) { - bool hasOverlap = true; + bool notHasOverlap = true; for (int i = 0; i < timePeriods.Count; i++) { @@ -308,13 +304,13 @@ namespace WebStarter.Controllers.BasicConfig { if (timePeriods[i].Contains(timePeriods[j]) || timePeriods[j].Contains(timePeriods[i])) { - hasOverlap = false; - return hasOverlap; + notHasOverlap = false; + return notHasOverlap; } } } - return hasOverlap; + return notHasOverlap; } ///