Exemple #1
0
        private static void CreateUser(CreateUserContext context)
        {
            context.Database.Initialize(true);

            var cmdText      = File.ReadAllText(UsersDataInsertionQueryPath);
            var affectedRows = context.Database.ExecuteSqlCommand(cmdText);

            Console.WriteLine(affectedRows);
        }
Exemple #2
0
 public static void Main()
 {
     using (CreateUserContext context = new CreateUserContext())
     {
         // CreateUser(context); // 8. Create User
         // GetUsersByEmailProvider(context); // 11. Get Users by Email Provider
         // RemoveInactiveUsers(context); // 12. Remove Inactive Users
     }
 }
Exemple #3
0
        private static void GetUsersByEmailProvider(CreateUserContext context)
        {
            Console.Write(GetUsersByEmailProviderUserLeadingToEnterTargetEmailEndMessage);
            var emailEndsWith = Console.ReadLine();

            var cmdText        = File.ReadAllText(GetUsersByEmailProviderSqlQueryPath);
            var selectedResult = context.Database.SqlQuery <string>(
                cmdText, new SqlParameter(GetUsersByEmailProviderParameterName, emailEndsWith)).ToList();

            Console.WriteLine(string.Join(Environment.NewLine, selectedResult));
        }
Exemple #4
0
        private static void RemoveInactiveUsers(CreateUserContext context)
        {
            Console.WriteLine(DeleteUsersWitLastLoginBeforeDateGetDateMessage);
            var deleteBefore = Console.ReadLine();

            // Mark users as deleted
            var markCmdText      = File.ReadAllText(MarkAsDeletedUserWithLoginBeforeDateQueryPath);
            var markAffectedRows = context.Database.ExecuteSqlCommand(markCmdText,
                                                                      new SqlParameter(MarkAsDeletedUserWithLoginBeforeDateParameterName, deleteBefore));

            Console.WriteLine((markAffectedRows > 0)
                ? string.Format(MarkAsDeletedUsersMessageWhenAtLeastOneIsMarked, markAffectedRows)
                : MarkAsDeletedUsersMessageWhenNoOneIsMarked);

            // Delete all marked users
            var deleteCmdText      = File.ReadAllText(DeleteAllMarkedUsersQueryPath);
            var deleteAffectedRows = context.Database.ExecuteSqlCommand(deleteCmdText);

            Console.WriteLine(string.Format(DeleteAllMarkedUsersMessage, deleteAffectedRows));
        }