Ejemplo n.º 1
0
        public override async Task <IdentityResult> CreateAsync(MangoUser user, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            try
            {
                await _userDbContext.MangoUsers.AddAsync(MEConversion.UserM2E(user));

                await _userDbContext.SaveChangesAsync();

                _userDbContext.ChangeTracker.Entries <UserEntity>().First().State = EntityState.Detached;
            }
            catch (DbUpdateConcurrencyException e)
            {
                return(IdentityResult.Failed(new IdentityError {
                    Description = e.Message
                }));
            }
            return(IdentityResult.Success);
        }
Ejemplo n.º 2
0
        public override async Task <IdentityResult> UpdateAsync(MangoUser user, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            _userDbContext.Update(MEConversion.UserM2E(user));

            try
            {
                await _userDbContext.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                return(IdentityResult.Failed(new IdentityError {
                    Description = e.Message
                }));
            }
            return(IdentityResult.Success);
        }