PIbd-21_Bakalskaya_E.D._Sus.../SushiBar/FormMails.cs

45 lines
1.4 KiB
C#
Raw Normal View History

2024-05-05 15:12:28 +04:00
using Microsoft.Extensions.Logging;
using SushiBarContracts.BusinessLogicsContracts;
namespace SushiBarView
{
public partial class FormMails : Form
{
private readonly ILogger logger;
private readonly IMessageInfoLogic messageInfoLogic;
public FormMails(ILogger<FormMails> logger, IMessageInfoLogic messageInfoLogic)
{
this.logger = logger;
this.messageInfoLogic = messageInfoLogic;
InitializeComponent();
}
private void LoadData()
{
try
{
var list = messageInfoLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["MessageId"].Visible = false;
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
logger.LogInformation("Load list of mails");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK);
logger.LogError("Load list of mails failed");
}
}
private void FormMails_Load(object sender, EventArgs e)
{
LoadData();
}
}
}