public string GetDisplayNameWithUnits() { if (!CustomAttributeType.MeasurementUnitTypeID.HasValue) { return(CustomAttributeType.CustomAttributeTypeName); } return ($"{CustomAttributeType.CustomAttributeTypeName} ({CustomAttributeType.GetMeasurementUnitDisplayName()})"); }
private string GetSelectionValue(CustomAttributeType attributeType, string attributeKey, string selectionKey) { if (attributeType == CustomAttributeType.Selection) { var selectionitem = _selectionDataItemRepository.Get(s => s.AttributeKey == attributeKey && s.SelectionKey == selectionKey); return(selectionitem == null ? string.Empty : selectionitem.Value); } return(""); }
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)); }
public AddCustomAttributeCommand(string extendableTypeName, CustomAttributeType customAttributeType, string category, string attributeKey, string attributeDetail, bool isRequired, int?maxLength, int?minValue, int?maxValue, bool?futureDateOnly, bool?pastDateOnly, bool isSearchable) : this() { ExtendableTypeName = extendableTypeName; CustomAttributeType = customAttributeType; Category = category; AttributeKey = attributeKey; AttributeDetail = attributeDetail; IsRequired = isRequired; MaxLength = maxLength; MinValue = minValue; MaxValue = maxValue; FutureDateOnly = futureDateOnly; PastDateOnly = pastDateOnly; IsSearchable = isSearchable; }
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)))); }
private PartialViewResult ViewDeleteCustomAttributeType(CustomAttributeType customAttributeType, ConfirmDialogFormViewModel viewModel) { var treatmentBMPTypeLabel = customAttributeType.TreatmentBMPTypeCustomAttributeTypes.Count == 1 ? FieldDefinitionType.TreatmentBMPType.GetFieldDefinitionLabel() : FieldDefinitionType.TreatmentBMPType.GetFieldDefinitionLabelPluralized(); var treatmentBMPLabel = customAttributeType.CustomAttributes.Count == 1 ? FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabel() : FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabelPluralized(); string confirmMessage; if (customAttributeType.CustomAttributeTypePurpose != CustomAttributeTypePurpose.Maintenance) { confirmMessage = $"Attribute Type '{customAttributeType.CustomAttributeTypeName}' is associated with {customAttributeType.TreatmentBMPTypeCustomAttributeTypes.Count} {treatmentBMPTypeLabel} and {customAttributeType.CustomAttributes.Count} {treatmentBMPLabel}.<br /><br />Are you sure you want to delete this {FieldDefinitionType.CustomAttributeType.GetFieldDefinitionLabel()}?"; } else { var maintenanceRecordCount = customAttributeType.MaintenanceRecordObservations.Select(x => x.MaintenanceRecord).Count(); var maintenanceRecordLabel = maintenanceRecordCount == 1 ? FieldDefinitionType.MaintenanceRecord.GetFieldDefinitionLabel() : FieldDefinitionType.MaintenanceRecord.GetFieldDefinitionLabelPluralized(); confirmMessage = $"Attribute Type '{customAttributeType.CustomAttributeTypeName}' is associated with {customAttributeType.TreatmentBMPTypeCustomAttributeTypes.Count} {treatmentBMPTypeLabel} and {maintenanceRecordCount} {maintenanceRecordLabel}.<br /><br />Are you sure you want to delete this {FieldDefinitionType.CustomAttributeType.GetFieldDefinitionLabel()}?"; } var viewData = new ConfirmDialogFormViewData(confirmMessage, true); return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel)); }
private static int ToCodedIndex(this int rowId, CustomAttributeType tag) => (rowId << (int)CustomAttributeType.__bits) | (int)tag;