Esempio n. 1
0
        /// <summary>
        /// Updates the <see cref="Specialization"/>.
        /// </summary>
        /// <returns>The new <see cref="Specialization"/> state.</returns>
        /// <param name="spec">Spec.</param>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="LeafRPCException"/>
        /// <exception cref="DbException"/>
        public async Task <Specialization> UpdateAsync(Specialization spec)
        {
            ThrowIfInvalid(spec);

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

                log.LogInformation("Update Specialization:{@Specialization}", updated);
                return(updated);
            }
            catch (DbException de)
            {
                log.LogError("Failed to update Specialization:{@Specialization}. Code:{Code} Error:{Error}", spec, de.ErrorCode, de.Message);
                de.MapThrow();
                throw;
            }
        }
Esempio n. 2
0
 void ThrowIfInvalid(Specialization spec)
 {
     Ensure.NotNull(spec, nameof(spec));
     Ensure.NotNullOrWhitespace(spec.UiDisplayText, nameof(spec.UiDisplayText));
     Ensure.NotNullOrWhitespace(spec.SqlSetWhere, nameof(spec.SqlSetWhere));
 }