Where is it permissible to add logging code in a MVC model?
Posted
by
BDotA
on Programmers
See other posts from Programmers
or by BDotA
Published on 2012-11-01T17:40:37Z
Indexed on
2012/11/01
23:20 UTC
Read the original article
Hit count: 325
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.");
}
}
}
}
© Programmers or respective owner