예제 #1
0
        private static void UpdateUser()
        {
            Console.Write("Enter an Id of user to update: ");
            input = Console.ReadLine();
            if (int.TryParse(input, out int userId))
            {
                User user = usersLogic.GetUserById(userId);
                if (user != null)
                {
                    ShowUser(user);
                    Console.Write("Enter new user date of birth in format yyyy-MM-dd: ");
                    input = Console.ReadLine();

                    if (DateTime.TryParseExact(input, DateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime userDateOfBirth))
                    {
                        if (usersLogic.Update(userId, userDateOfBirth))
                        {
                            Console.WriteLine("User updated successfully.");
                            Console.WriteLine();
                        }
                        else
                        {
                            UserUpdatingError();
                        }
                    }
                    else
                    {
                        UserUpdatingError();
                    }
                }
                else
                {
                    UserUpdatingError();
                }
            }
            else
            {
                UserUpdatingError();
            }
        }
예제 #2
0
 public User GetUserById(Guid id) => _logic.GetUserById(id);