Exemple #1
0
 public SafeGroup Add(SafeGroup safeGroup, int callerId)
 {
     using (UBContext ubc = new UBContext())
     {
         try
         {
             ubc.Add(safeGroup);
             ubc.SaveChanges();
             return(safeGroup);
         }
         catch (Exception ex)
         {
             Utils.Logging.AddLog(new SystemLog()
             {
                 LoggerName = "Unifiedban",
                 Date       = DateTime.Now,
                 Function   = "Unifiedban.Data.SafeGroupService.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.SafeGroupService.Add",
                     Level      = SystemLog.Levels.Warn,
                     Message    = ex.InnerException.Message,
                     UserId     = callerId
                 });
             }
         }
         return(null);
     }
 }
Exemple #2
0
        public Banned Add(Banned banned, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                try
                {
                    using (var transaction = ubc.Database.BeginTransaction())
                    {
                        try
                        {
                            ubc.Add(banned);
                            ubc.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.User_Banned ON;");
                            ubc.SaveChanges();
                            ubc.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.User_Banned OFF");
                            transaction.Commit();

                            return(banned);
                        }
                        catch (Exception ex)
                        {
                            Utils.Logging.AddLog(new SystemLog()
                            {
                                LoggerName = "Unifiedban",
                                Date       = DateTime.Now,
                                Function   = "Unifiedban.Data.BannedService.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.BannedService.Add",
                                    Level      = SystemLog.Levels.Warn,
                                    Message    = ex.InnerException.Message,
                                    UserId     = callerId
                                });
                            }

                            return(null);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.BannedService.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.BannedService.Add",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(null);
            }
        }