private async Task <bool> HasUniqueAddress(Home entity)
        {
            var uow        = UnitOfWorkScope.GetUnitOfWork(false);
            var repository = uow.GetRepository <Home>();

            var exists = await repository.AnyAsync(x => x.Address.Equals(entity.Address, StringComparison.OrdinalIgnoreCase));

            return(!exists);
        }
        public async Task DeleteAsync(int?id, object input = null)
        {
            if (!id.HasValue)
            {
                return;
            }

            var uow = UnitOfWorkScope.GetUnitOfWork(true);

            var repository = uow.GetRepository <Person>();

            repository.Remove(id.Value);
            await uow.SaveChangesAsync();
        }
Esempio n. 3
0
        public async Task PostprocessForGet(int id, GetInput <Home> input, Home result)
        {
            if (string.IsNullOrWhiteSpace(result?.Address))
            {
                return;
            }

            // Get the people living on the same address.
            // Normally this would be done with an include of some kind.
            // We just included this for the sake of the async example.
            var uow        = UnitOfWorkScope.GetUnitOfWork(false);
            var repository = uow.GetRepository <Person>();

            var peopleOnSameAddress = await repository.QueryAsync(x => x.Address == result.Address);

            result.Habitants = peopleOnSameAddress;
        }