2
I have a class that loga some information in the database I am using it in the following way:
new StudyLogRepository().Create(new StudyLog() {
StudyId = Study.Id,
CycleId = null,
DateOccurrence = DateTime.Now,
CycleActionName = "Nova estudo gerado",
UserId = int.Parse(System.Web.HttpContext.Current.Session[SessionKeys.USER_ID].ToString())
});
But in the same method I end up having to log in various information, so I end up having this code duplicated in several classes and methods making maintenance super complicated.
How can I solve this my duplicate code problem being that the data to be logged always comes directly from the class or method where there is this duplicate snippet?