public MunicipalityTax AddOrUpdate(MunicipalityTax municipalityTax)
 {
     _dbContext.Entry(municipalityTax).State = municipalityTax.MunicipalityId > 0 ? EntityState.Modified : EntityState.Added;
     try
     {
         _dbContext.SaveChanges();
     }
     catch (DbEntityValidationException dbEx)
     {
         _logger.Error(dbEx, $"Failed to execute Entity Add Or Update: {typeof(MunicipalityTax).Name}.");
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 Trace.TraceInformation("Property: {0} Error: {1}",
                                        validationError.PropertyName,
                                        validationError.ErrorMessage);
                 throw new Exception(validationError.ErrorMessage, dbEx);
             }
         }
     }
     return(municipalityTax);
 }
示例#2
0
 public override void Log(ExceptionLoggerContext context)
 {
     _logger.Error(context.ExceptionContext.Exception, context.Request.RequestUri.ToString());
 }
 public void SqlServerLogging_Test_ErrorLog()
 {
     structuredLogger.Error("Error - This is test message from LoggerCases Test class- function: SqlServerLogging_Test_ErrorLog");
 }