Ejemplo n.º 1
0
        void ISecurityRepository.UpdateCredentials(Guid userId, LoginCredentials credentials)
        {
            try
            {
                using (var dc = CreateContext())
                {
                    var entity = GetRegisteredUserEntity(dc, userId);
                    if (entity != null)
                    {
                        credentials.MapTo(entity);
                        dc.SubmitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                // Now look for a duplicate error.

                if (ex is SqlException && ex.Message.StartsWith("Cannot insert duplicate key row in object 'dbo.RegisteredUserLoginId' with unique index "))
                {
                    throw new DuplicateUserException();
                }
                throw;
            }
        }