Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 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);
     }
 }