Пример #1
0
        /// <summary>
        /// Updates the <see cref="AdminGlobalPanelFilter"/>.
        /// </summary>
        /// <returns>Updated <see cref="AdminGlobalPanelFilter"/>.</returns>
        /// <param name="pf">The new <see cref="AdminGlobalPanelFilter"/> state.</param>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="LeafRPCException"/>
        /// <exception cref="DbException"/>
        public async Task <AdminGlobalPanelFilter> UpdateAsync(AdminGlobalPanelFilter pf)
        {
            ThrowIfInvalid(pf);

            try
            {
                var updated = await svc.UpdateAsync(pf);

                if (updated != null)
                {
                    log.LogInformation("Updated GlobalPanelFilter:{@GlobalPanelFilter}", updated);
                }
                else
                {
                    log.LogInformation("Could not update GlobalPanelFilter:{@GlobalPanelFilter}, not found", pf);
                }
                return(updated);
            }
            catch (DbException de)
            {
                log.LogInformation("Failed to update GlobalPanelFilter. GlobalPanelFilter:{@GlobalPanelFilter} Code:{Code} Error:{Error}", pf, de.ErrorCode, de.Message);
                de.MapThrow();
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new <see cref="AdminGlobalPanelFilter"/>.
        /// </summary>
        /// <returns>Created <see cref="AdminGlobalPanelFilter"/>.</returns>
        /// <param name="pf"><see cref="AdminGlobalPanelFilter"/>.</param>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="LeafRPCException"/>
        /// <exception cref="DbException"/>
        public async Task <AdminGlobalPanelFilter> CreateAsync(AdminGlobalPanelFilter pf)
        {
            ThrowIfInvalid(pf);

            try
            {
                var created = await svc.CreateAsync(pf);

                log.LogInformation("Created GlobalPanelFilter:{@GlobalPanelFilter}", created);
                return(created);
            }
            catch (DbException de)
            {
                log.LogError("Failed to create GlobalPanelFilter. GlobalPanelFilter:{@GlobalPanelFilter}. Code:{Code} Error:{Error}", pf, de.ErrorCode, de.Message);
                de.MapThrow();
                throw;
            }
        }
Пример #3
0
 void ThrowIfInvalid(AdminGlobalPanelFilter panelFilter)
 {
     Ensure.NotNull(panelFilter, nameof(panelFilter.SqlSetId));
 }