public BadImage Update(BadImage badImage, int callerId) { using (UBContext ubc = new UBContext()) { BadImage exists = ubc.BadImages .Where(x => x.BadImageId == badImage.BadImageId) .FirstOrDefault(); if (exists == null) { return(null); } try { exists.GroupId = badImage.GroupId; exists.HashData = badImage.HashData; exists.ParentImageId = badImage.ParentImageId; exists.FlipType = badImage.FlipType; exists.Status = badImage.Status; exists.Match = badImage.Match; ubc.SaveChanges(); return(badImage); } catch (Exception ex) { Utils.Logging.AddLog(new SystemLog() { LoggerName = "Unifiedban", Date = DateTime.Now, Function = "Unifiedban.Data.BadImageService.Update", Level = SystemLog.Levels.Warn, Message = ex.Message, UserId = callerId }); if (ex.InnerException != null) { Utils.Logging.AddLog(new SystemLog() { LoggerName = "Unifiedban.Data", Date = DateTime.Now, Function = "Unifiedban.Data.BadImageService.Update", Level = SystemLog.Levels.Warn, Message = ex.InnerException.Message, UserId = callerId }); } } return(null); } }
public SystemLog.ErrorCodes Remove(BadImage badImage, int callerId) { using (UBContext ubc = new UBContext()) { BadImage exists = ubc.BadImages .Where(x => x.BadImageId == badImage.BadImageId) .FirstOrDefault(); if (exists == null) { return(SystemLog.ErrorCodes.Error); } try { ubc.SaveChanges(); return(SystemLog.ErrorCodes.OK); } catch (Exception ex) { Utils.Logging.AddLog(new SystemLog() { LoggerName = "Unifiedban", Date = DateTime.Now, Function = "Unifiedban.Data.BadImageService.Remove", Level = SystemLog.Levels.Warn, Message = ex.Message, UserId = callerId }); if (ex.InnerException != null) { Utils.Logging.AddLog(new SystemLog() { LoggerName = "Unifiedban.Data", Date = DateTime.Now, Function = "Unifiedban.Data.BadImageService.Remove", Level = SystemLog.Levels.Warn, Message = ex.InnerException.Message, UserId = callerId }); } } return(SystemLog.ErrorCodes.Error); } }
public BadImage Add(BadImage badImage, int callerId) { using (UBContext ubc = new UBContext()) { try { ubc.Add(badImage); ubc.SaveChanges(); return(badImage); } catch (Exception ex) { Utils.Logging.AddLog(new SystemLog() { LoggerName = "Unifiedban", Date = DateTime.Now, Function = "Unifiedban.Data.BadImageService.Add", Level = SystemLog.Levels.Warn, Message = ex.Message, UserId = callerId }); if (ex.InnerException != null) { Utils.Logging.AddLog(new SystemLog() { LoggerName = "Unifiedban.Data", Date = DateTime.Now, Function = "Unifiedban.Data.BadImageService.Add", Level = SystemLog.Levels.Warn, Message = ex.InnerException.Message, UserId = callerId }); } } return(null); } }