Exemple #1
0
        public ViewResult Edit(CustomAttributeTypePrimaryKey customAttributeTypePrimaryKey)
        {
            var customAttributeType = customAttributeTypePrimaryKey.EntityObject;
            var viewModel           = new EditViewModel(customAttributeType);

            return(ViewEdit(viewModel, customAttributeType));
        }
Exemple #2
0
        private ViewResult ViewEdit(EditViewModel viewModel, CustomAttributeType customAttributeType)
        {
            var instructionsNeptunePage = NeptunePage.GetNeptunePageByPageType(NeptunePageType.ManageCustomAttributeTypeInstructions);
            var customAttributeInstructionsNeptunePage = NeptunePage.GetNeptunePageByPageType(NeptunePageType.ManageCustomAttributeInstructions);

            var submitUrl = ModelObjectHelpers.IsRealPrimaryKeyValue(viewModel.CustomAttributeTypeID) ? SitkaRoute <CustomAttributeTypeController> .BuildUrlFromExpression(x => x.Edit(viewModel.CustomAttributeTypeID)) : SitkaRoute <CustomAttributeTypeController> .BuildUrlFromExpression(x => x.New());

            var viewData = new EditViewData(CurrentPerson, MeasurementUnitType.All, CustomAttributeDataType.All, submitUrl, instructionsNeptunePage, customAttributeInstructionsNeptunePage, customAttributeType);

            return(RazorView <Edit, EditViewData, EditViewModel>(viewData, viewModel));
        }
Exemple #3
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))));
        }
Exemple #4
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))));
        }
Exemple #5
0
        public ViewResult New()
        {
            var viewModel = new EditViewModel();

            return(ViewEdit(viewModel, null));
        }