private void AuditLog(smART.ViewModel.Scale businessEntity, smART.Model.smARTDBContext dbContext) { try { smART.Model.AuditLog newModObject = new Model.AuditLog() { Entity_Name = "Scale", Entity_ID = businessEntity.ID, Field_Name = "Scale_Reading", Old_Value = businessEntity.Scale_Reading.ToString(), New_Value = businessEntity.Scale_Reading.ToString(), Active_Ind = true, Created_By = businessEntity.Updated_By, Updated_By = businessEntity.Updated_By, Created_Date = businessEntity.Last_Updated_Date, Last_Updated_Date = businessEntity.Last_Updated_Date }; dbContext.T_Audit_Log.Add(newModObject); dbContext.SaveChanges(); } catch (Exception ex) { bool rethrow; rethrow = BusinessRuleExceptionHandler.HandleException(ref ex, businessEntity.Updated_By, businessEntity.GetType().Name, businessEntity.ID.ToString()); if (rethrow) { throw ex; } } }
public void AddAuditLog(RouteData routeData, string strRemoteIp, ResultExecutedContext resultState) { try { Model.AuditLog lstLog = new Model.AuditLog(); lstLog.User_Id = Convert.ToInt16(routeData.Values["id"]); lstLog.Description = "Process : " + routeData.Values["controller"]; lstLog.Type = "Id : " + resultState.Result; lstLog.HostName = Dns.GetHostName(); lstLog.IpAddress = strRemoteIp; lstLog.Status = ActionStat(Convert.ToString(routeData.Values["action"])); lstLog.AddedBy = Convert.ToInt16(routeData.Values["id"]); lstLog.AddedOn = DateTime.Now; adbContext.auditlog.Add(lstLog); adbContext.SaveChangesAsync(); } catch (Exception ex) { //Write Log manually in text file Logfile.Error("Error on AuditLog", ex); } }