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); }
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); }
public async void Delete(int id) { if (await _listRep.Get(id) == null) { return; } _listRep.Delete(id); _uow.Commit(); }
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)); }
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); }
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); }
public Task Execute(DeleteListCommand command) { return(repo.Delete(command.Id)); }
public async Task DeleteList(Guid id, string userId) { await _listRepository.Delete(id, userId); }