Exemple #1
0
 internal bool Create(Guid tenantId, TenantSubscriptionEntityDetailInfo info)
 {
     try
     {
         var cmd = CreateProcedureCommand("dbo.TenantSubscriptionEntityDetail_Create");
         cmd.AppendGuid("@guidTenantId", tenantId);
         cmd.AppendGuid("@guidSubscriptionEntityDetailId", info.SubscriptionEntityDetailId);
         cmd.AppendGuid("@guidSubscriptionEntityId", info.SubscriptionEntityId);
         cmd.AppendGuid("@guidContext", info.Context);
         if (info.RecurringPrice.HasValue && info.RecurringPrice.Value > 0)
         {
             cmd.AppendDecimal("@dRecurringPrice", info.RecurringPrice.Value);
             cmd.AppendTinyInt("@tinyintRecurringDuration", (byte)info.RecurringDuration);
         }
         if (info.OneTimePrice.HasValue && info.OneTimePrice.Value > 0)
         {
             cmd.AppendDecimal("@dOneTimePrice", info.OneTimePrice.Value);
             cmd.AppendTinyInt("@tinyintOneTimeDuration", (byte)info.OneTimeDuration);
         }
         ExecuteCommand(cmd);
         return(true);
     }
     catch (SqlException e)
     {
         throw ReportAndTranslateException(e, "TenantSubscriptionEntityDetail::TenantSubscriptionEntityDetail_Create");
     }
 }
Exemple #2
0
        private static TenantSubscriptionEntityDetailInfo ReadInfo(SqlDataReader reader)
        {
            var role = new TenantSubscriptionEntityDetailInfo
            {
                SubscriptionEntityDetailId = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0),
                SubscriptionEntityId       = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1),
                Context           = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2),
                RecurringPrice    = reader.IsDBNull(3) ? (decimal?)null : reader.GetDecimal(3),
                RecurringDuration = reader.IsDBNull(4) ? SubscriptionDuration.Weekly : (SubscriptionDuration)reader.GetByte(4),
                OneTimePrice      = reader.IsDBNull(5) ? (decimal?)null : reader.GetDecimal(5),
                OneTimeDuration   = reader.IsDBNull(6) ? SubscriptionDuration.Weekly : (SubscriptionDuration)reader.GetByte(6)
            };

            return(role);
        }
        public IActionResult Post([FromBody] TenantSubscriptionEntityDetailInfo info)
        {
            try
            {
                if (info == null)
                {
                    return(BadRequest("Invalid parameter"));
                }

                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SubscriptionEntityDetailController Post {0}=", JsonConvert.SerializeObject(info));
                var subscriptionEntityDetailId = _managerEntityDetail.Create(TenantCode, info);
                stopwatch.StopAndLog("End SubscriptionEntityDetailController Post");
                return(Ok(subscriptionEntityDetailId));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Exemple #4
0
        internal TenantSubscriptionEntityDetailInfo TenantSubscriptionEntityDetail(Guid tenantId, Guid tenantSubscriptionEntityDetailId)
        {
            TenantSubscriptionEntityDetailInfo info = null;

            try
            {
                var cmd = CreateProcedureCommand("dbo.TenantSubscriptionEntityDetail_Get");
                cmd.AppendGuid("@guidTenantId", tenantId);
                cmd.AppendGuid("@guidTenantSubscriptionEntityDetailId", tenantSubscriptionEntityDetailId);
                using (SqlDataReader reader = ExecuteCommandAndReturnReader(cmd))
                {
                    while (reader.Read())
                    {
                        info = ReadInfo(reader);
                    }
                }
            }
            catch (SqlException e)
            {
                throw ReportAndTranslateException(e, "TenantSubscriptionEntityDetail::TenantSubscriptionEntityDetail_Get");
            }
            return(info);
        }
 bool IAdminTenantSubscriptionEntityDetail.Update(Guid tenantId, TenantSubscriptionEntityDetailInfo info)
 {
     return(_data.Update(tenantId, info));
 }
Exemple #6
0
 bool IManagerTenantSubscriptionEntityDetail.Update(Guid tenantId, TenantSubscriptionEntityDetailInfo info)
 {
     return(_adminTenantSubscriptionEntityDetail.Update(tenantId, info));
 }
Exemple #7
0
 Guid IManagerTenantSubscriptionEntityDetail.Create(Guid tenantId, TenantSubscriptionEntityDetailInfo info)
 {
     info.SubscriptionEntityDetailId = Guid.NewGuid();
     _adminTenantSubscriptionEntityDetail.Create(tenantId, info);
     return(info.SubscriptionEntityDetailId);
 }