Example #1
0
        public ActionResult Edit(CustomAttributeTypePrimaryKey customAttributeTypePrimaryKey, EditViewModel viewModel)
        {
            var customAttributeType = customAttributeTypePrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEdit(viewModel, customAttributeType));
            }
            viewModel.UpdateModel(customAttributeType, CurrentPerson);

            return(RedirectToAction(new SitkaRoute <CustomAttributeTypeController>(c => c.Detail(customAttributeType.PrimaryKey))));
        }
Example #2
0
        public ActionResult New(EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(viewModel, null));
            }

            var customAttributeTypePurpose = CustomAttributeTypePurpose.AllLookupDictionary[viewModel.CustomAttributeTypePurposeID.GetValueOrDefault()];

            var customAttributeType = new CustomAttributeType(String.Empty, CustomAttributeDataType.String, false, customAttributeTypePurpose);

            viewModel.UpdateModel(customAttributeType, CurrentPerson);
            HttpRequestStorage.DatabaseEntities.CustomAttributeTypes.Add(customAttributeType);
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay($"Custom Attribute Type {customAttributeType.CustomAttributeTypeName} succesfully created.");

            return(RedirectToAction(new SitkaRoute <CustomAttributeTypeController>(c => c.Detail(customAttributeType.PrimaryKey))));
        }