Where is it permissible to add logging code in a MVC model?
- by BDotA
Working on a C# WinForms program that is written in a MVC ( actually Model-View-Presenter) style and I want to add a few lines of code that is responsible for logging some events. Where should I write two or three lines of code that I need? Should I write it in the Presenter section?
To get an idea, here is some lines of sample code that already exists in the Save() metohd in Company.MyApplication.Presenter.MyPresenter.cs class:
he has written codes lie the following in this part of presenter:
private void Save(Helper.SaveStatusEnum status)
{
if (notification.CheckLocks(orderIdCollection))
{
using (new HourglassController())
{
controller.FireActiveCellLeaving();
ViewDocumentedValues();
int result = saveController.Save(status);
if (result == Helper.SAVE_SUCCESSFUL)
{
// IS IT OK TO WRITE MY COUPLE LINES OF CODE IN HERE???????????
model.Dirty = false;
if ((model.CurrentStatus == Helper.OrderStatusEnum.Complete) || (model.CurrentStatus == Helper.OrderStatusEnum.Corrected))
{
controller.EnableDisableSheet(false);
}
CheckApplicationState();
SheetHelper.ClearUnsavedDataRowImage(view.ActiveSheet);
}
else
{
MessageBox.Show("An unexpected error occuring trying to save.");
}
}
}
}