Ejemplo n.º 1
0
        public ActionResult Create(MetaFormViewModel model)
        {
            var availableMetaTypes = _metaRepository.GetMetaTypeProperties();

            if (ModelState.IsValid)
            {
                if (_metaRepository.CheckMetaTypeNameAvailability(model.MetaTypeName, model.Id))
                {
                    var availableMetaType = availableMetaTypes.FirstOrDefault(m => m.FullPropertyName == model.SelectedMetaTypeValue);
                    if (availableMetaType != null)
                    {
                        var metaType = new CCM.Core.Entities.MetaType()
                        {
                            FullPropertyName = availableMetaType.FullPropertyName,
                            Name             = model.MetaTypeName,
                            PropertyName     = availableMetaType.PropertyName,
                            Type             = availableMetaType.Type,
                            CreatedBy        = User.Identity.Name,
                            UpdatedBy        = User.Identity.Name
                        };

                        _metaRepository.Save(metaType);

                        return(RedirectToAction("Index"));
                    }
                }
            }

            model.MetaTypeValues = availableMetaTypes;
            return(View(model));
        }