Esempio n. 1
0
        public async Task <IdentityResult> DeleteAsync(Customer user, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();
            Guard.NotNull(user, nameof(user));

            if (user.IsSystemAccount)
            {
                throw new SmartException($"System customer account ({user.SystemName}) cannot be deleted.");
            }

            _db.Remove(user);

            try
            {
                await SaveChanges(cancellationToken);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Failed(ErrorDescriber.ConcurrencyFailure()));
            }

            return(IdentityResult.Success);
        }