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

                if (result)
                {
                    AlertSuccess = $"Successfully added group type <strong>{message}</strong>.";
                }
                else
                {
                    AlertDanger = $"Could not add group type: {message}";
                }
            }
            return(RedirectToAction("Index",
                                    new { page = viewModel?.PaginateModel?.CurrentPage ?? 1 }));
        }
Пример #2
0
        public async Task <IActionResult> Delete(GroupTypesListViewModel viewModel)
        {
            if (viewModel.GroupType == null)
            {
                AlertWarning = "Unable to remove group type - must supply an id.";
            }
            else
            {
                string result
                    = await _groupTypesService.Remove(GetActiveUserId(), viewModel.GroupType.Id);

                if (string.IsNullOrEmpty(result))
                {
                    AlertSuccess = $"Successfully removed group type <strong>{viewModel.GroupType.Name}</strong>.";
                }
                else
                {
                    AlertDanger = $"Could not remove group type {viewModel.GroupType.Name}: {result}";
                }
            }

            return(RedirectToAction("Index",
                                    new { page = viewModel?.PaginateModel?.CurrentPage ?? 1 }));
        }