예제 #1
0
 public ActionResult Update(ResourceGroup resourceGroup)
 {
     if (!_securityService.CanUpdate(resourceGroup))
     {
         return(RedirectToAction("ForbiddenError", "Home"));
     }
     if (resourceGroup == null)
     {
         return(RedirectToAction("BadRequestError", "Home",
                                 new { message = "Не передана ссылка на категорию ресурсов" }));
     }
     if (!ModelState.IsValid)
     {
         ViewData["SecurityService"] = _securityService;
         return(View(resourceGroup));
     }
     try
     {
         _resourceGroupService.UpdateResourceGroup(resourceGroup);
         _resourceGroupService.SaveChanges();
     }
     catch (DbUpdateException e)
     {
         return(RedirectToAction("ConflictError", "Home",
                                 new { message = ExceptionHelper.RollToInnerException(e).Message }));
     }
     return(Request["returnUri"] != null ? (ActionResult)Redirect(Request["returnUri"]) :
            RedirectToAction("Index"));
 }
예제 #2
0
        private async void UpdateGroup_OnClick(object sender, RoutedEventArgs e)
        {
            RegistryCommon.Instance.MainProgressBar.Text = StatusBarState.Saving;
            if (_allGroups.Any(g => g.Name == GroupNameTextBox.Text && _selectedGroup.Name != g.Name))
            {
                MessageBox.Show(
                    "Група з таким іменем вже існує. Виберіть іньше ім'я",
                    "Помилка",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                RegistryCommon.Instance.MainProgressBar.Text = StatusBarState.Failed;
                return;
            }

            await _resourceGroupService.UpdateResourceGroup(_selectedGroup.Id, GroupNameTextBox.Text);

            RegistryCommon.Instance.MainProgressBar.Text = StatusBarState.Saved;

            RegistryCommon.Instance.MainGrid.OpenUserControlWithSignOut(new Themes(ThemeFilterTextBox.Text));
        }