public DataResult <bool> UpdateClaimType(ClaimTypeModel claimTypeModel)
        {
            var claimType = new ClaimTypeEntity
            {
                Name        = claimTypeModel.Name,
                Description = claimTypeModel.Description
            };

            try
            {
                m_claimTypeUoW.UpdateClaimType(claimTypeModel.Id, claimType, claimTypeModel.SelectedType);
                return(Success(true));
            }
            catch (NoResultException <ClaimTypeEntity> e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(m_translator.Translate("invalid-claim-type-id"), DataResultErrorCode.ClaimTypeNotExistId));
            }
            catch (NoResultException <ClaimTypeEnumEntity> e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(m_translator.Translate("invalid-claim-type-enum-id"), DataResultErrorCode.ClaimTypeEnumNotExistId));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(e.Message));
            }
        }
Beispiel #2
0
        public virtual int CreateClaimType(ClaimTypeEntity claimType, int claimTypeEnumId)
        {
            var claimTypeEnum = m_claimTypeEnumRepository.FindById <ClaimTypeEnumEntity>(claimTypeEnumId);

            claimType.Type = claimTypeEnum ?? throw new NoResultException <ClaimTypeEnumEntity>();

            var result = (int)m_claimTypeRepository.Create(claimType);

            return(result);
        }
Beispiel #3
0
        public virtual void UpdateClaimType(int claimTypeId, ClaimTypeEntity claimType, int claimTypeEnumId)
        {
            var claimTypeEntity = m_claimTypeRepository.FindClaimTypeById(claimTypeId);

            if (claimTypeEntity == null)
            {
                throw new NoResultException <ClaimTypeEntity>();
            }

            var type = m_claimTypeEnumRepository.FindById <ClaimTypeEnumEntity>(claimTypeEnumId);

            claimTypeEntity.Type        = type ?? throw new NoResultException <ClaimTypeEnumEntity>();
            claimTypeEntity.Name        = claimType.Name;
            claimTypeEntity.Description = claimType.Description;

            m_claimTypeRepository.Update(claimTypeEntity);
        }