|
@@ -26,25 +26,19 @@ public class AdoS0OrderPriorityRulesController : ControllerBase
|
|
|
(q.Page, q.PageSize) = PagingGuard.Normalize(q.Page, q.PageSize);
|
|
(q.Page, q.PageSize) = PagingGuard.Normalize(q.Page, q.PageSize);
|
|
|
|
|
|
|
|
var query = _rep.AsQueryable()
|
|
var query = _rep.AsQueryable()
|
|
|
- .WhereIF(q.CompanyRefId.HasValue, x => x.CompanyRefId == q.CompanyRefId.Value)
|
|
|
|
|
- .WhereIF(q.FactoryRefId.HasValue, x => x.FactoryRefId == q.FactoryRefId.Value)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.DomainCode), x => x.DomainCode == q.DomainCode)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.DomainCode), x => x.DomainCode == q.DomainCode)
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.Descr), x => x.Descr.Contains(q.Descr!))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.Descr), x => x.Descr.Contains(q.Descr!))
|
|
|
.WhereIF(q.Priority.HasValue, x => x.Priority == q.Priority.Value)
|
|
.WhereIF(q.Priority.HasValue, x => x.Priority == q.Priority.Value)
|
|
|
|
|
+ .WhereIF(q.OrderBy.HasValue, x => x.OrderBy == q.OrderBy.Value)
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.SourceTable), x => x.SourceTable != null && x.SourceTable.Contains(q.SourceTable!))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.SourceTable), x => x.SourceTable != null && x.SourceTable.Contains(q.SourceTable!))
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.SourceColumn), x => x.SourceColumn != null && x.SourceColumn.Contains(q.SourceColumn!))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.SourceColumn), x => x.SourceColumn != null && x.SourceColumn.Contains(q.SourceColumn!))
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.Value), x => x.Value != null && x.Value.Contains(q.Value!))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(q.Value), x => x.Value != null && x.Value.Contains(q.Value!))
|
|
|
- .WhereIF(!string.IsNullOrWhiteSpace(q.ScopeCustClass), x => x.ScopeCustClass != null && x.ScopeCustClass.Contains(q.ScopeCustClass!))
|
|
|
|
|
- .WhereIF(!string.IsNullOrWhiteSpace(q.ScopeOrderType), x => x.ScopeOrderType != null && x.ScopeOrderType.Contains(q.ScopeOrderType!))
|
|
|
|
|
- .WhereIF(q.ScopeDueDaysMax.HasValue, x => x.ScopeDueDaysMax == q.ScopeDueDaysMax!.Value)
|
|
|
|
|
.WhereIF(q.IsActive.HasValue, x => x.IsActive == q.IsActive.Value)
|
|
.WhereIF(q.IsActive.HasValue, x => x.IsActive == q.IsActive.Value)
|
|
|
.WhereIF(
|
|
.WhereIF(
|
|
|
!string.IsNullOrWhiteSpace(q.Keyword),
|
|
!string.IsNullOrWhiteSpace(q.Keyword),
|
|
|
x => x.Descr.Contains(q.Keyword!) ||
|
|
x => x.Descr.Contains(q.Keyword!) ||
|
|
|
(x.SourceTable != null && x.SourceTable.Contains(q.Keyword!)) ||
|
|
(x.SourceTable != null && x.SourceTable.Contains(q.Keyword!)) ||
|
|
|
- (x.Value != null && x.Value.Contains(q.Keyword!)) ||
|
|
|
|
|
- (x.ScopeCustClass != null && x.ScopeCustClass.Contains(q.Keyword!)) ||
|
|
|
|
|
- (x.ScopeOrderType != null && x.ScopeOrderType.Contains(q.Keyword!)));
|
|
|
|
|
|
|
+ (x.Value != null && x.Value.Contains(q.Keyword!)));
|
|
|
|
|
|
|
|
var total = await query.CountAsync();
|
|
var total = await query.CountAsync();
|
|
|
var list = await query
|
|
var list = await query
|
|
@@ -54,17 +48,17 @@ public class AdoS0OrderPriorityRulesController : ControllerBase
|
|
|
.ToListAsync();
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
foreach (var x in list)
|
|
foreach (var x in list)
|
|
|
- x.OrderByText = AdoS0SalesRules.PriorityCodeOrderByText(x.OrderByCode);
|
|
|
|
|
|
|
+ x.OrderByText = AdoS0SalesRules.PriorityCodeOrderByText(x.OrderBy);
|
|
|
|
|
|
|
|
return Ok(new { total, page = q.Page, pageSize = q.PageSize, list });
|
|
return Ok(new { total, page = q.Page, pageSize = q.PageSize, list });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [HttpGet("{id:long}")]
|
|
|
|
|
- public async Task<IActionResult> GetAsync(long id)
|
|
|
|
|
|
|
+ [HttpGet("{id}")]
|
|
|
|
|
+ public async Task<IActionResult> GetAsync(string id)
|
|
|
{
|
|
{
|
|
|
var item = await _rep.GetByIdAsync(id);
|
|
var item = await _rep.GetByIdAsync(id);
|
|
|
if (item == null) return NotFound();
|
|
if (item == null) return NotFound();
|
|
|
- item.OrderByText = AdoS0SalesRules.PriorityCodeOrderByText(item.OrderByCode);
|
|
|
|
|
|
|
+ item.OrderByText = AdoS0SalesRules.PriorityCodeOrderByText(item.OrderBy);
|
|
|
return Ok(item);
|
|
return Ok(item);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -74,24 +68,20 @@ public class AdoS0OrderPriorityRulesController : ControllerBase
|
|
|
var now = DateTime.Now;
|
|
var now = DateTime.Now;
|
|
|
var entity = new AdoS0PriorityCode
|
|
var entity = new AdoS0PriorityCode
|
|
|
{
|
|
{
|
|
|
- CompanyRefId = dto.CompanyRefId,
|
|
|
|
|
- FactoryRefId = dto.FactoryRefId,
|
|
|
|
|
DomainCode = dto.DomainCode,
|
|
DomainCode = dto.DomainCode,
|
|
|
- Descr = dto.Descr,
|
|
|
|
|
|
|
+ Descr = dto.Descr ?? string.Empty,
|
|
|
Value = dto.Value,
|
|
Value = dto.Value,
|
|
|
Priority = dto.Priority,
|
|
Priority = dto.Priority,
|
|
|
- OrderByCode = dto.OrderByCode,
|
|
|
|
|
|
|
+ OrderBy = dto.OrderBy,
|
|
|
SourceTable = dto.SourceTable,
|
|
SourceTable = dto.SourceTable,
|
|
|
SourceColumn = dto.SourceColumn,
|
|
SourceColumn = dto.SourceColumn,
|
|
|
SourceType = dto.SourceType,
|
|
SourceType = dto.SourceType,
|
|
|
SourceId = dto.SourceId,
|
|
SourceId = dto.SourceId,
|
|
|
ValueType = dto.ValueType,
|
|
ValueType = dto.ValueType,
|
|
|
ValueId = dto.ValueId,
|
|
ValueId = dto.ValueId,
|
|
|
- ScopeCustClass = dto.ScopeCustClass,
|
|
|
|
|
- ScopeOrderType = dto.ScopeOrderType,
|
|
|
|
|
- ScopeDueDaysMax = dto.ScopeDueDaysMax,
|
|
|
|
|
IsActive = dto.IsActive,
|
|
IsActive = dto.IsActive,
|
|
|
CreateUser = dto.CreateUser,
|
|
CreateUser = dto.CreateUser,
|
|
|
|
|
+ LegacyCreateUser = dto.LegacyCreateUser,
|
|
|
CreateTime = now,
|
|
CreateTime = now,
|
|
|
UpdateUser = dto.UpdateUser,
|
|
UpdateUser = dto.UpdateUser,
|
|
|
UpdateTime = null
|
|
UpdateTime = null
|
|
@@ -101,38 +91,34 @@ public class AdoS0OrderPriorityRulesController : ControllerBase
|
|
|
return Ok(entity);
|
|
return Ok(entity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [HttpPut("{id:long}")]
|
|
|
|
|
- public async Task<IActionResult> UpdateAsync(long id, [FromBody] AdoS0PriorityCodeUpsertDto dto)
|
|
|
|
|
|
|
+ [HttpPut("{id}")]
|
|
|
|
|
+ public async Task<IActionResult> UpdateAsync(string id, [FromBody] AdoS0PriorityCodeUpsertDto dto)
|
|
|
{
|
|
{
|
|
|
var entity = await _rep.GetByIdAsync(id);
|
|
var entity = await _rep.GetByIdAsync(id);
|
|
|
if (entity == null) return NotFound();
|
|
if (entity == null) return NotFound();
|
|
|
|
|
|
|
|
- entity.CompanyRefId = dto.CompanyRefId;
|
|
|
|
|
- entity.FactoryRefId = dto.FactoryRefId;
|
|
|
|
|
entity.DomainCode = dto.DomainCode;
|
|
entity.DomainCode = dto.DomainCode;
|
|
|
- entity.Descr = dto.Descr;
|
|
|
|
|
|
|
+ entity.Descr = dto.Descr ?? string.Empty;
|
|
|
entity.Value = dto.Value;
|
|
entity.Value = dto.Value;
|
|
|
entity.Priority = dto.Priority;
|
|
entity.Priority = dto.Priority;
|
|
|
- entity.OrderByCode = dto.OrderByCode;
|
|
|
|
|
|
|
+ entity.OrderBy = dto.OrderBy;
|
|
|
entity.SourceTable = dto.SourceTable;
|
|
entity.SourceTable = dto.SourceTable;
|
|
|
entity.SourceColumn = dto.SourceColumn;
|
|
entity.SourceColumn = dto.SourceColumn;
|
|
|
entity.SourceType = dto.SourceType;
|
|
entity.SourceType = dto.SourceType;
|
|
|
entity.SourceId = dto.SourceId;
|
|
entity.SourceId = dto.SourceId;
|
|
|
entity.ValueType = dto.ValueType;
|
|
entity.ValueType = dto.ValueType;
|
|
|
entity.ValueId = dto.ValueId;
|
|
entity.ValueId = dto.ValueId;
|
|
|
- entity.ScopeCustClass = dto.ScopeCustClass;
|
|
|
|
|
- entity.ScopeOrderType = dto.ScopeOrderType;
|
|
|
|
|
- entity.ScopeDueDaysMax = dto.ScopeDueDaysMax;
|
|
|
|
|
entity.IsActive = dto.IsActive;
|
|
entity.IsActive = dto.IsActive;
|
|
|
entity.UpdateUser = dto.UpdateUser;
|
|
entity.UpdateUser = dto.UpdateUser;
|
|
|
|
|
+ entity.LegacyCreateUser = dto.LegacyCreateUser;
|
|
|
entity.UpdateTime = DateTime.Now;
|
|
entity.UpdateTime = DateTime.Now;
|
|
|
|
|
|
|
|
await _rep.AsUpdateable(entity).ExecuteCommandAsync();
|
|
await _rep.AsUpdateable(entity).ExecuteCommandAsync();
|
|
|
return Ok(entity);
|
|
return Ok(entity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [HttpPatch("{id:long}/toggle-enabled")]
|
|
|
|
|
- public async Task<IActionResult> ToggleActiveAsync(long id, [FromBody] AdoS0PriorityCodeToggleActiveDto dto)
|
|
|
|
|
|
|
+ [HttpPatch("{id}/toggle-enabled")]
|
|
|
|
|
+ public async Task<IActionResult> ToggleActiveAsync(string id, [FromBody] AdoS0PriorityCodeToggleActiveDto dto)
|
|
|
{
|
|
{
|
|
|
var entity = await _rep.GetByIdAsync(id);
|
|
var entity = await _rep.GetByIdAsync(id);
|
|
|
if (entity == null) return NotFound();
|
|
if (entity == null) return NotFound();
|
|
@@ -144,8 +130,8 @@ public class AdoS0OrderPriorityRulesController : ControllerBase
|
|
|
return Ok(entity);
|
|
return Ok(entity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [HttpDelete("{id:long}")]
|
|
|
|
|
- public async Task<IActionResult> DeleteAsync(long id)
|
|
|
|
|
|
|
+ [HttpDelete("{id}")]
|
|
|
|
|
+ public async Task<IActionResult> DeleteAsync(string id)
|
|
|
{
|
|
{
|
|
|
var item = await _rep.GetByIdAsync(id);
|
|
var item = await _rep.GetByIdAsync(id);
|
|
|
if (item == null) return NotFound();
|
|
if (item == null) return NotFound();
|