public ApiSecretDto GetApiSecret(int?id)
        {
            ApiSecretDto apiSecretDto = new ApiSecretDto();

            if (!id.HasValue && id.GetValueOrDefault() <= 0)
            {
                return(apiSecretDto);
            }
            ApiSecret apiSecret = this.Session.Get <ApiSecret>(id.Value);

            if (apiSecret == null)
            {
                return(apiSecretDto);
            }
            return(apiSecret.ToModel());
        }
        public void AddApiSecret(ApiSecretDto apiSecretDto)
        {
            apiSecretDto.HashApiSharedSecret();
            var transaction = this.Session.BeginTransaction();

            try
            {
                var apiSecret = apiSecretDto.ToEntity();
                this.Session.Save(apiSecret);

                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
        }
        public void UpdateApiSecret(int id, ApiSecretDto apiSecretDto)
        {
            apiSecretDto.HashApiSharedSecret();
            var transaction = this.Session.BeginTransaction();

            try
            {
                ApiSecret apiSecret = this.Session.Get <ApiSecret>(id);
                apiSecret = apiSecretDto.ToEntity(apiSecret);
                this.Session.Update(apiSecret);

                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
        }
 public IActionResult UpdateApiSecret(int id, [FromBody] ApiSecretDto apiSecretDto)
 {
     this.service.UpdateApiSecret(id, apiSecretDto);
     return(Success());
 }
 public IActionResult AddApiSecret([FromBody] ApiSecretDto apiSecretDto)
 {
     this.service.AddApiSecret(apiSecretDto);
     return(Success());
 }
        public IActionResult GetApiSecret(int?id)
        {
            ApiSecretDto data = this.service.GetApiSecret(id);

            return(Success(data));
        }
 public static ApiSecret ToEntity(this ApiSecretDto apiSecretDto, ApiSecret apiSecret = null)
 {
     return(Mapper.Map <ApiSecretDto, ApiSecret>(apiSecretDto, apiSecret));
 }