コード例 #1
0
        public async Task <IActionResult> EditConfigurationItem(int id)
        {
            var viewModel = new EditConfigurationItemViewModel();

            var response = await _adminService.GetConfigurationItem(new GetConfigurationItemRequest()
            {
                Id = id
            });

            if (!response.IsSuccessful)
            {
                AddNotifications(response);
                return(View(viewModel));
            }

            viewModel.Key     = response.ConfigurationItem.Key;
            viewModel.Request = new UpdateConfigurationItemRequest()
            {
                Id            = response.ConfigurationItem.Id,
                Description   = response.ConfigurationItem.Description,
                BooleanValue  = response.ConfigurationItem.Boolean_Value,
                DateTimeValue = response.ConfigurationItem.DateTime_Value,
                DecimalValue  = response.ConfigurationItem.Decimal_Value,
                IntValue      = response.ConfigurationItem.Int_Value,
                MoneyValue    = response.ConfigurationItem.Money_Value,
                StringValue   = response.ConfigurationItem.String_Value,
            };

            return(View(viewModel));
        }
コード例 #2
0
        public async Task <IActionResult> EditConfigurationItem(UpdateConfigurationItemRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = await _adminService.UpdateConfigurationItem(request);

                if (response.IsSuccessful)
                {
                    AddNotifications(response);
                    return(RedirectToAction(nameof(AdminController.ConfigurationManagement)));
                }
                AddFormErrors(response);
            }
            var viewModel = new EditConfigurationItemViewModel(request);

            return(View(viewModel));
        }