Browse Source

Create EventHubPageModel.ShowAlert

pull/15/head
Halil İbrahim Kalkan 6 years ago
parent
commit
a5334a71fb
  1. 15
      eventhub/src/EventHub.Web/Pages/EventHubPageModel.cs
  2. 12
      eventhub/src/EventHub.Web/Pages/Organizations/New.cshtml.cs

15
eventhub/src/EventHub.Web/Pages/EventHubPageModel.cs

@ -1,4 +1,7 @@
using EventHub.Localization;
using System;
using EventHub.Localization;
using Microsoft.Extensions.Logging;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace EventHub.Web.Pages
@ -9,5 +12,13 @@ namespace EventHub.Web.Pages
{
LocalizationResourceType = typeof(EventHubResource);
}
protected void ShowAlert(Exception exception)
{
Logger.LogException(exception);
var errorInfoConverter = LazyServiceProvider.LazyGetRequiredService<IExceptionToErrorInfoConverter>();
var errorInfo = errorInfoConverter.Convert(exception, false);
Alerts.Danger(errorInfo.Message);
}
}
}
}

12
eventhub/src/EventHub.Web/Pages/Organizations/New.cshtml.cs

@ -4,8 +4,6 @@ using System.Threading.Tasks;
using EventHub.Organizations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form;
namespace EventHub.Web.Pages.Organizations
@ -17,14 +15,10 @@ namespace EventHub.Web.Pages.Organizations
public CreateOrganizationViewModel Organization { get; set; }
private readonly IOrganizationAppService _organizationAppService;
private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
public New(
IOrganizationAppService organizationAppService,
IExceptionToErrorInfoConverter errorInfoConverter)
public New(IOrganizationAppService organizationAppService)
{
_organizationAppService = organizationAppService;
_errorInfoConverter = errorInfoConverter;
}
public void OnGet()
@ -45,9 +39,7 @@ namespace EventHub.Web.Pages.Organizations
}
catch (Exception exception)
{
Logger.LogException(exception);
var errorInfo = _errorInfoConverter.Convert(exception, false);
Alerts.Danger(errorInfo.Message);
ShowAlert(exception);
return Page();
}
}

Loading…
Cancel
Save