Пример #1
0
        public async Task <IActionResult> AddDescriptionGroup(DescriptionGroupDto descriptionGroupDto)
        {
            if (descriptionGroupDto == null)
            {
                return(RedirectToAction("DescriptionGroups"));
            }

            var descriptionGroup = _mapper.Map <DescriptionGroup>(descriptionGroupDto);

            OperationResult result = await _shopManager.CreateDescriptionGroupAsync(descriptionGroup);

            if (!result.Succeeded)
            {
                TempData["Message"] = string.Join(Environment.NewLine, result.Errors.Select(x => x.Description));
            }
            else
            {
                TempData["Message"] = $"Группа \"{descriptionGroup.Name}\" успешно добавлена.";
            }

            return(RedirectToAction("DescriptionGroups"));
        }