public ActionResult CreateActiveSpecificationType()
        {
            var model       = new ActiveSpecificationTypeCreateModel();
            var activeTypes = activeTypesService.GetAllActiveTypes();

            foreach (var item in activeTypes)
            {
                model.ActiveTypeItems.Add(new SelectListItem
                {
                    Text  = item.TypeCode + " (" + item.TypeName + ") ",
                    Value = item.Id.ToString()
                });
            }

            return(View(model));
        }
        public ActionResult CreateActiveSpecificationType(ActiveSpecificationTypeCreateModel newSpecification)
        {
            var activeTypes = activeTypesService.GetAllActiveTypes();

            foreach (var item in activeTypes)
            {
                newSpecification.ActiveTypeItems.Add(new SelectListItem
                {
                    Text  = item.TypeCode + " (" + item.TypeName + ") ",
                    Value = item.Id.ToString()
                });
            }

            if (ModelState.IsValid)
            {
                foreach (var itemType in newSpecification.ActiveTypeId)
                {
                    var createSpecification = new ActiveSpecificationType
                    {
                        ActiveTypeId = itemType,
                        TypeName     = newSpecification.TypeName,
                        MeasureType  = newSpecification.MeasureType
                    };
                    var validation = catalogsValidator.NeedSaveSpecificationType(createSpecification);
                    //проверка на существование повторяющейся записи. сохранение только в случае, если такой записи нет
                    if (validation.IsValid)
                    {
                        activeSpecificationTypeService.SaveActiveSpecificationType(createSpecification);
                    }
                    else
                    {
                        ViewBag.WarningMessage = validation.ValidationMessage;
                        return(View(newSpecification));
                    }
                }
                return(RedirectToAction("Index"));
            }

            return(View(newSpecification));
        }