Base solution for your next web application
Open Closed

Delete command don't execute ? #8131


User avatar
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)
  • User Avatar
    0
    maliming created
    Support Team

    Please share the complete code and error stack information.

  • User Avatar
    0
    troyfernando created

    No errors found. it seems updateitemno method is affecting the delete command. it works when i remove updateitemno method.

  • User Avatar
    0
    maliming created
    Support Team

    Please share the code of Updateitemno method .

  • User Avatar
    0
    troyfernando created

    public Task Updateitemno(int parentID, bool isNew) { DNEthanRepositoryExtensions.updateitemno<Estimatecuttinglist, int>(_estimatecuttinglistRepository, parentID, isNew); return Task.CompletedTask; }

        public static void updateitemno&lt;TEntity, TPrimaryKey&gt;(this IRepository&lt;TEntity, TPrimaryKey&gt; repository, int parentID , bool isNeworDelete) where TEntity : class, IEntity&lt;TPrimaryKey&gt;, 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++;
            }
        }
    
  • User Avatar
    0
    maliming created
    Support Team

    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
    
    }
    
  • User Avatar
    0
    troyfernando created

    thanx