Example #1
0
        public static bool DeleteUserLogins(string connectionString, IEnumerable <UserLogin> userLogins)
        {
            try
            {
                using (var context = new UserLoginDBContext(connectionString))
                {
                    foreach (var userLogin in userLogins.Select(userLogin => new UserLogin()
                    {
                        ID = userLogin.ID
                    }))
                    {
                        context.UserLogins.Attach(userLogin);
                        context.UserLogins.Remove(userLogin);
                    }

                    var result = context.SaveChanges();
                    return(result > 0);
                }
            }
            catch (Exception exception)
            {
                NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                                    ExceptionResources.ExceptionOccuredLogDetail);
                return(false);
            }
        }
Example #2
0
 public static bool AddUserLogin(string connectionString, UserLogin userLogin)
 {
     try
     {
         using (var context = new UserLoginDBContext(connectionString))
         {
             context.UserLogins.Add(userLogin);
             var result = context.SaveChanges();
             return(result > 0);
         }
     }
     catch (Exception exception)
     {
         NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                             ExceptionResources.ExceptionOccuredLogDetail);
         return(false);
     }
 }
 public static bool AddUserLogin(string connectionString, UserLogin userLogin)
 {
     try
     {
         using (var context = new UserLoginDBContext(connectionString))
         {
             context.UserLogins.Add(userLogin);
             var result = context.SaveChanges();
             return result > 0;
         }
     }
     catch (Exception exception)
     {
         NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                             ExceptionResources.ExceptionOccuredLogDetail);
         return false;
     }
 }
        public static bool DeleteUserLogins(string connectionString, IEnumerable<UserLogin> userLogins)
        {
            try
            {
                using (var context = new UserLoginDBContext(connectionString))
                {
                    foreach (var userLogin in userLogins.Select(userLogin => new UserLogin() { ID = userLogin.ID }))
                    {
                        context.UserLogins.Attach(userLogin);
                        context.UserLogins.Remove(userLogin);
                    }

                    var result = context.SaveChanges();
                    return result > 0;
                }
            }
            catch (Exception exception)
            {
                NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                                    ExceptionResources.ExceptionOccuredLogDetail);
                return false;
            }
        }