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; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace EventHub.Web.Pages namespace EventHub.Web.Pages
@ -9,5 +12,13 @@ namespace EventHub.Web.Pages
{ {
LocalizationResourceType = typeof(EventHubResource); 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 EventHub.Organizations;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form;
namespace EventHub.Web.Pages.Organizations namespace EventHub.Web.Pages.Organizations
@ -17,14 +15,10 @@ namespace EventHub.Web.Pages.Organizations
public CreateOrganizationViewModel Organization { get; set; } public CreateOrganizationViewModel Organization { get; set; }
private readonly IOrganizationAppService _organizationAppService; private readonly IOrganizationAppService _organizationAppService;
private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
public New( public New(IOrganizationAppService organizationAppService)
IOrganizationAppService organizationAppService,
IExceptionToErrorInfoConverter errorInfoConverter)
{ {
_organizationAppService = organizationAppService; _organizationAppService = organizationAppService;
_errorInfoConverter = errorInfoConverter;
} }
public void OnGet() public void OnGet()
@ -45,9 +39,7 @@ namespace EventHub.Web.Pages.Organizations
} }
catch (Exception exception) catch (Exception exception)
{ {
Logger.LogException(exception); ShowAlert(exception);
var errorInfo = _errorInfoConverter.Convert(exception, false);
Alerts.Danger(errorInfo.Message);
return Page(); return Page();
} }
} }

Loading…
Cancel
Save