0
troyfernando created
public async Task Delete(EntityDto input) { int parentID = _estimatecuttinglistRepository.FirstOrDefault(input.Id).parentID;
_estimatecuttinglistRepository.Delete(input.Id); -- records not deleted
await Updateitemno(parentID, true); -- executed
}
I having problem when deleting records after i insert the Updateitemno command.
6 Answer(s)
-
0
Please share the complete code and error stack information.
-
0
No errors found. it seems updateitemno method is affecting the delete command. it works when i remove updateitemno method.
-
0
Please share the code of
Updateitemno
method . -
0
public Task Updateitemno(int parentID, bool isNew) { DNEthanRepositoryExtensions.updateitemno<Estimatecuttinglist, int>(_estimatecuttinglistRepository, parentID, isNew); return Task.CompletedTask; }
public static void updateitemno<TEntity, TPrimaryKey>(this IRepository<TEntity, TPrimaryKey> repository, int parentID , bool isNeworDelete) where TEntity : class, IEntity<TPrimaryKey>, IMayHaveItemno { if (!isNeworDelete) return; var item = from db in repository.GetAll() where db.parentID == parentID orderby db.itemno select db; int itemno = 1; foreach (var row in item) { row.itemno = itemno; repository.Update(row); itemno++; } }
-
0
Please try
unitOfWorkManager.Current.SaveChangesAsync(
public async Task Delete(EntityDto input) { int parentID = _estimatecuttinglistRepository.FirstOrDefault(input.Id).parentID; _estimatecuttinglistRepository.Delete(input.Id); -- records not deleted await _unitOfWorkManager.Current.SaveChangesAsync(); await Updateitemno(parentID, true); -- executed }
-
0
thanx