|
@ -78,25 +78,40 @@ namespace Win.Sfs.SettleAccount.Entities.Prices |
|
|
|
|
|
|
|
|
var pricelist = GetPriceList(version); |
|
|
var pricelist = GetPriceList(version); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var LeftJoin = from emp in ListOfEmployees
|
|
|
//var LeftJoin = from emp in ListOfEmployees
|
|
|
// join dept in ListOfDepartment
|
|
|
// join dept in ListOfDepartment
|
|
|
// on emp.DeptID equals dept.ID into JoinedEmpDept
|
|
|
// on emp.DeptID equals dept.ID into JoinedEmpDept
|
|
|
// from dept in JoinedEmpDept.DefaultIfEmpty()
|
|
|
// from dept in JoinedEmpDept.DefaultIfEmpty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var add= from itm1 in entities join itm2 in pricelist |
|
|
|
|
|
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode } |
|
|
|
|
|
into temp from itm3 in temp.DefaultIfEmpty() where itm3 == null select itm1; |
|
|
|
|
|
|
|
|
|
|
|
var update = from itm1 in entities |
|
|
var update = from itm1 in entities |
|
|
join itm2 in pricelist |
|
|
join itm2 in pricelist |
|
|
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode } |
|
|
on new { itm1.Type, itm1.MaterialCode } equals new { itm2.Type, itm2.MaterialCode } |
|
|
where itm1.Price != itm2.Price |
|
|
where itm1.Price != itm2.Price |
|
|
select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode,itm2.Type, itm2.ParentId, itm2.Version); |
|
|
select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode); |
|
|
|
|
|
|
|
|
|
|
|
if (update.Count() > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var add = from itm1 in entities |
|
|
|
|
|
join itm2 in pricelist |
|
|
|
|
|
on new { itm1.Type, itm1.MaterialCode } |
|
|
|
|
|
equals new { itm2.Type, itm2.MaterialCode } |
|
|
|
|
|
into temp |
|
|
|
|
|
from itm3 in temp.DefaultIfEmpty() |
|
|
|
|
|
where itm3 == null |
|
|
|
|
|
select itm1; |
|
|
|
|
|
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); |
|
|
|
|
|
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _first = _versionRepository.FirstOrDefault(p => p.Version == version); |
|
|
var _first = _versionRepository.FirstOrDefault(p => p.Version == version); |
|
@ -113,7 +128,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices |
|
|
public virtual async Task<PriceList> CreateAsync(PriceList input) |
|
|
public virtual async Task<PriceList> CreateAsync(PriceList input) |
|
|
{ |
|
|
{ |
|
|
var entity = new PriceList( |
|
|
var entity = new PriceList( |
|
|
GuidGenerator.Create(), input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.ParentId,input.Version |
|
|
GuidGenerator.Create(), input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.ParentId,input.Version,input.CustomerCode |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
return await _repository.InsertAsync(entity); |
|
|
return await _repository.InsertAsync(entity); |
|
@ -125,7 +140,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices |
|
|
{ |
|
|
{ |
|
|
var entity = await _repository.GetAsync(id); |
|
|
var entity = await _repository.GetAsync(id); |
|
|
entity.Set( |
|
|
entity.Set( |
|
|
input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type |
|
|
input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.CustomerCode |
|
|
); |
|
|
); |
|
|
return await _repository.UpdateAsync(entity); |
|
|
return await _repository.UpdateAsync(entity); |
|
|
|
|
|
|
|
|