Пример #1
0
        public void ListRepository_GetAllItems()
        {
            var items        = _listRepository.FindAll();
            var initialCount = items.Count;
            var testEntity   = GetTestEntity();

            _listRepository.Create(testEntity);
            Assert.IsTrue(_listRepository.FindAll().Count == (initialCount + 1));
            Assert.IsTrue(_listRepository.Delete(testEntity));
            Assert.IsTrue(_listRepository.FindAll().Count == initialCount);
        }
Пример #2
0
        internal static Guid CanNotDelete <TEntity>(this IListRepository <TEntity, Guid> repo) where TEntity : BaseEntity
        {
            var id = Guid.NewGuid();

            repo.Delete(id).Returns(new Result <TEntity>().AddErrorMessage("Not found"));

            return(id);
        }
Пример #3
0
 public async void Delete(int id)
 {
     if (await _listRep.Get(id) == null)
     {
         return;
     }
     _listRep.Delete(id);
     _uow.Commit();
 }
Пример #4
0
        public virtual Result <bool> Delete(TModel model)
        {
            if (model?.Id == null)
            {
                return(new ErrorResult <bool>("Unknown Entity"));
            }

            Repository.Delete(model.Id.Value);
            return(new SuccessResult <bool>(true));
        }
Пример #5
0
        public void Delete(long id)
        {
            var entity      = GetOne(id);
            var listItemIds = entity.Items.Select(x => x.Id).ToArray();

            foreach (var itemId in listItemIds)
            {
                var entityToDelete = _listItemRepository.First(x => x.Id == itemId);
                _listItemRepository.Delete(entityToDelete);
            }
            _listRepository.Delete(entity);
        }
Пример #6
0
        internal static TEntity CanDelete <TEntity>(this IListRepository <TEntity, Guid> repo) where TEntity : BaseEntity
        {
            var id     = Guid.NewGuid();
            var entity = Activator.CreateInstance <TEntity>();

            entity.Id = id;
            repo.Delete(id).Returns(new Result <TEntity>()
            {
                Return = entity
            });

            return(entity);
        }
Пример #7
0
 public Task Execute(DeleteListCommand command)
 {
     return(repo.Delete(command.Id));
 }
Пример #8
0
 public async Task DeleteList(Guid id, string userId)
 {
     await _listRepository.Delete(id, userId);
 }