Пример #1
0
        public async Task <IActionResult> Edit(GroupTypesListViewModel viewModel)
        {
            if (viewModel.GroupType == null ||
                string.IsNullOrEmpty(viewModel.GroupType.Name) ||
                string.IsNullOrEmpty(viewModel.GroupType.Name.Trim()))
            {
                AlertWarning = "Unable to modify group type - must supply a name.";
            }
            else
            {
                var(result, message) = await _groupTypesService.Edit(GetActiveUserId(),
                                                                     viewModel.GroupType.Id,
                                                                     viewModel.GroupType.Name);

                if (result)
                {
                    AlertSuccess = $"Successfully modified group type <strong>{message}</strong>.";
                }
                else
                {
                    AlertDanger = $"Could not modify group type: {message}";
                }
            }
            return(RedirectToAction("Index",
                                    new { page = viewModel?.PaginateModel?.CurrentPage ?? 1 }));
        }