Esempio n. 1
0
        /// <summary>
        /// Method for editing the user. Promote, Demote, activate or deactivate
        /// </summary>
        /// <param name="admin">Takes a user with admin priviliges</param>
        /// <param name="editUser">Takes a user to edit</param>
        private static void EditUser(User admin, User editUser)
        {
            var continueLoop = true;

            do
            {
                AdminView.EditUser(editUser);
                var input = SharedController.GetAndValidateInput();
                switch (input.validatedInput)
                {
                case 1:
                    if (api.Promote(admin.Id, editUser.Id))
                    {
                        SharedError.Success();
                        break;
                    }
                    SharedError.Failed();
                    break;

                case 2:
                    if (api.Demote(admin.Id, editUser.Id))
                    {
                        SharedError.Success();
                        break;
                    }
                    SharedError.Failed();
                    break;

                case 3:
                    if (api.ActivateUser(admin.Id, editUser.Id))
                    {
                        SharedError.Success();
                        break;
                    }
                    SharedError.Failed();
                    break;

                case 4:
                    if (api.InactivateUser(admin.Id, editUser.Id))
                    {
                        SharedError.Success();
                        break;
                    }
                    SharedError.Failed();
                    break;

                case 0:
                    continueLoop = SharedController.GoBackIf_X_IsPressedOrPrintErrorMsg(input.menuInput);
                    break;

                default:
                    SharedError.PrintWrongMenuInput();
                    break;
                }
            } while (continueLoop);
        }