public bool Handler(Dalyan.Domain.Query.LogDatabaseDeleteQuery query) { try { var obj = new Dalyan.Db.LogDatabase(); obj = _db.LogDatabase.FirstOrDefault(x => x.Id == query.Id); obj.IsDeleted = true; _db.SaveChanges(); return(true); } catch (Exception ex) { throw new ExceptionLog(LogType.DATABASE_DELETE, LogLevel.ERROR, ex, "DeleteQueryHandler"); } }
private void WriteLog(LogType logtype, LogLevel loglevel, Exception ex, String message) { try { Dalyan.Db.LogDatabase log = new Dalyan.Db.LogDatabase(); log.Comment = message; log.ExceptionString = ex.ToString(); log.LogDate = DateTime.Now; log.LogLevel = loglevel.ToString(); log.LogType = logtype.ToString(); log.IsDeleted = false; _db.LogDatabase.Add(log); _db.SaveChanges(); } catch (Exception exLog) { WriteLogToFile(logtype, loglevel, ex, message, exLog); } }
public Dalyan.Entities.Models.LogDatabase Handler(LogDatabaseEditQuery query) { try { var obj = new Dalyan.Db.LogDatabase(); obj = _db.LogDatabase.FirstOrDefault(x => x.Id == query.LogDatabase.Id); obj.Id = query.LogDatabase.Id; obj.UserId = query.LogDatabase.UserId; obj.LogDate = query.LogDatabase.LogDate; obj.LogType = query.LogDatabase.LogType; obj.LogLevel = query.LogDatabase.LogLevel; obj.ExceptionString = query.LogDatabase.ExceptionString; obj.Comment = query.LogDatabase.Comment; obj.IsDeleted = query.LogDatabase.IsDeleted; _db.SaveChanges(); return(query.LogDatabase); } catch (Exception ex) { throw new ExceptionLog(LogType.DATABASE_UPDATE, LogLevel.ERROR, ex, "EditQueryHandler"); } }
public Dalyan.Entities.Models.LogDatabase Handler(LogDatabaseAddQuery query) { try { var obj = new Dalyan.Db.LogDatabase(); obj.Id = query.LogDatabase.Id; obj.UserId = query.LogDatabase.UserId; obj.LogDate = query.LogDatabase.LogDate; obj.LogType = query.LogDatabase.LogType; obj.LogLevel = query.LogDatabase.LogLevel; obj.ExceptionString = query.LogDatabase.ExceptionString; obj.Comment = query.LogDatabase.Comment; obj.IsDeleted = query.LogDatabase.IsDeleted; _db.LogDatabase.Add(obj); _db.SaveChanges(); query.LogDatabase.Id = obj.Id; return(query.LogDatabase); } catch (Exception ex) { throw new ExceptionLog(LogType.DATABASE_INSERT, LogLevel.ERROR, ex, "AddQueryHandler"); } }