public bool AddLogMessage(LogMessage logMessage, bool bSave) { Debug.WriteLine(GetType().FullName + "." + MethodBase.GetCurrentMethod().Name); //want to force this to hit the db if the model is invalid logMessage = (LogMessage) logMessage.ForceValidData(); _context.LogMessages.Add(logMessage); return !bSave || Save(); }
public bool UpdateLogMessage(LogMessage item, bool bSave) { Debug.WriteLine(GetType().FullName + "." + MethodBase.GetCurrentMethod().Name); //want to force this to hit the db if the model is invalid item = (LogMessage)item.ForceValidData(); var oldItem = _context.LogMessages.FirstOrDefault(x => x.Id == item.Id); if (oldItem != null && oldItem.Id != default(int)) { _context.LogMessages.Remove(oldItem); _context.LogMessages.Add(item); return !bSave || Save(); } else return false; }