diff --git a/Myshipping.Application/Service/DataSync/DataSyncService.cs b/Myshipping.Application/Service/DataSync/DataSyncService.cs index 32119c8e..8da51341 100644 --- a/Myshipping.Application/Service/DataSync/DataSyncService.cs +++ b/Myshipping.Application/Service/DataSync/DataSyncService.cs @@ -276,7 +276,7 @@ namespace Myshipping.Application { throw Oops.Bah("简称未录入"); } - var m = mlist.Where(x => x.ShortName == item.ShortName).First(); + var m = mlist.Where(x => x.ShortName == item.ShortName).FirstOrDefault(); var entity = item.Adapt(); if (m == null) { @@ -310,7 +310,7 @@ namespace Myshipping.Application if (entity.PropString.Contains("shipagency")) { - var ship = shiplist.Where(x => x.Code == entity.CodeName).First(); + var ship = shiplist.Where(x => x.Code == entity.CodeName).FirstOrDefault(); if (ship == null) { @@ -375,7 +375,7 @@ namespace Myshipping.Application if (entity.PropString.Contains("shipagency")) { - var ship = shiplist.Where(x => x.Code == entity.CodeName).First(); + var ship = shiplist.Where(x => x.Code == entity.CodeName).FirstOrDefault(); if (ship == null) { @@ -421,10 +421,10 @@ namespace Myshipping.Application public async Task SyncVesselDateList(List model) { - var mapcarrier = await _mapcarrier.Where(x => x.Module == "HeChuan").ToListAsync(); - var userlist = _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync(); - var mlist = await _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).ToListAsync(); - var orderlist= await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); + var mapcarrier = _mapcarrier.Where(x => x.Module == "HeChuan").ToList(); + var userlist = _repUser.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList(); + var mlist = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).ToList(); + var orderlist= _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToList(); foreach (var item in model) { @@ -433,7 +433,7 @@ namespace Myshipping.Application throw Oops.Bah("BSNO未录入"); } - var m = mlist.Where(x => x.BSNO == item.BSNO).First(); + var m = mlist.Where(x => x.BSNO == item.BSNO).FirstOrDefault(); var entity = item.Adapt(); entity.Vessel = item.Vessel.ToUpper().Trim(); if (!string.IsNullOrEmpty(item.CARRIER)) @@ -456,7 +456,7 @@ namespace Myshipping.Application if (!string.IsNullOrEmpty(item.CreatedUserName)) { - entity.CreatedUserId = userlist.Result.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault(); + entity.CreatedUserId = userlist.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault(); } if (string.IsNullOrEmpty(item.Voyno)) { @@ -598,12 +598,12 @@ namespace Myshipping.Application throw Oops.Bah("未录入创建人"); } - var user = userlist.Where(x => x.Name == model.CreatedUserName.Trim() && x.IsDeleted == false).First(); + var user = userlist.Where(x => x.Name == model.CreatedUserName.Trim() && x.IsDeleted == false).FirstOrDefault(); if (user == null) { throw Oops.Bah($"未匹配到创建人{model.CreatedUserName.Trim()}请联系管理员添加相关用户"); } - var order = orderlist.Where(x => x.BSNO == model.BSNO ).First(); + var order = orderlist.Where(x => x.BSNO == model.BSNO ).FirstOrDefault(); if (order == null) @@ -687,7 +687,7 @@ namespace Myshipping.Application } if (!string.IsNullOrEmpty(entity.LineName)) { - var line = linelist.Where(m => m.LineName.Contains(entity.LineName)).First(); + var line = linelist.Where(m => m.LineName.Contains(entity.LineName)).FirstOrDefault(); if (line == null) { await _repline.InsertAsync(new DjyTenantLine @@ -1678,7 +1678,7 @@ namespace Myshipping.Application foreach (var item in dto) { - var model = infolist.Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno).First(); + var model = infolist.Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno).FirstOrDefault(); if (model != null) { model.ETA = item.ETA; @@ -1829,7 +1829,7 @@ namespace Myshipping.Application foreach (var item in dto) { - //var model = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno && x.TenantId == UserManager.TENANT_ID).First(); + //var model = _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.Vessel == item.Vessel && x.Voyno == item.Voyno && x.TenantId == UserManager.TENANT_ID).FirstOrDefault(); //model.ETA = item.ETA; //model.ETD = item.ETD; //model.ATD = item.ATD;