public bool UpdateLog(LogDto dto) { var log = this.db.Logs.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (log != null) { log.UpdatedOn = DateTime.Now; log.UpdatedBy = dto.UpdatedBy; log.Comment = dto.Comment; log.LogEventId = dto.LogEvent.Id; log.Expression = dto.Expression; log.OldRow = dto.OldRow; log.NewRow = dto.NewRow; this.db.SaveChanges(); return true; } return false; }
public bool AddLog(LogDto dto) { if (!this.db.Logs.Any(x => x.DeletedOn.HasValue == false && x.Id == dto.Id)) { this.db.Logs.Add(new Log { CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UpdatedBy = dto.UpdatedBy, Comment = dto.Comment, LogEventId = dto.LogEvent.Id, Expression = dto.Expression, OldRow = dto.OldRow, NewRow = dto.NewRow }); this.db.SaveChanges(); return true; } return false; }