Beispiel #1
0
        protected override void CustomizeControls()
        {
            var isCurrentUserSeller    = SecurityService.IsCurrentUserSeller;
            var isCurrentUserPurchaser = SecurityService.IsCurrentUserPurchaser;

            switch (Mode)
            {
            case EditFormMode.View:
                base.CustomizeControls();
                break;

            case EditFormMode.Create:
                CheckHelper.WithinCondition(isCurrentUserSeller, "Only seller can create order item.");

                ControlCustomizeHelper.CustomizeControl(_orderReferenceEditor, EditFormMode.Create);
                ControlCustomizeHelper.CustomizeControl(_productSizeReferenceEditor, EditFormMode.Create);
                ControlCustomizeHelper.CustomizeControl(_quantityNumericUpDown, EditFormMode.Create);
                ControlCustomizeHelper.CustomizeControl(_priceNumericUpDown, EditFormMode.Create);
                ControlCustomizeHelper.CustomizeControl(_activeCheckBox, EditFormMode.Create);
                ControlCustomizeHelper.CustomizeControl(_purchaserPaidNumericUpDown,
                                                        isCurrentUserPurchaser ? EditFormMode.Create : EditFormMode.View);
                break;

            case EditFormMode.Edit:
                CheckHelper.WithinCondition(
                    isCurrentUserPurchaser || isCurrentUserSeller,
                    "Only purchaser and seller can change order item.");

                var editFormModeForPurchaser = isCurrentUserPurchaser ? EditFormMode.Edit : EditFormMode.View;
                var editFormModeForSeller    = Dto.IsCurrentUserSellerForOrderItem() ? EditFormMode.Edit : EditFormMode.View;

                ControlCustomizeHelper.CustomizeControl(_orderReferenceEditor, editFormModeForSeller);
                ControlCustomizeHelper.CustomizeControl(_productSizeReferenceEditor, editFormModeForSeller);
                ControlCustomizeHelper.CustomizeControl(_quantityNumericUpDown, editFormModeForSeller);
                ControlCustomizeHelper.CustomizeControl(_priceNumericUpDown, editFormModeForSeller);
                ControlCustomizeHelper.CustomizeControl(_activeCheckBox, editFormModeForSeller);
                ControlCustomizeHelper.CustomizeControl(_purchaserPaidNumericUpDown, editFormModeForPurchaser);
                break;

            default:
                throw new NotSupportedException(Mode.ToString());
            }
        }