private List<Field> BuildFields(OrgUnitTypeDto orgUnitTypeDto, bool newItem) { var fields = new List<Field>(); var isReservedLocationType = CheckForReservedLocationTypes(orgUnitTypeDto); if (isReservedLocationType) { fields.Add(new Field("reservedMessage", string.Empty, FieldTypes.Html, "<div class='alert alert-info'>This Location Type cannot be edited.</div>")); } fields.Add(new Field(_idField, "Id", (newItem ? FieldTypes.Hidden : FieldTypes.Label), orgUnitTypeDto.Id)); fields.Add(new Field(_nameField, "Name", FieldTypes.Text, orgUnitTypeDto.Name, true)); fields.Add(new Field(_isEnabledField, "Enabled", FieldTypes.Checkbox, (newItem ? true : orgUnitTypeDto.IsEnabled))); fields.Add(new Field(_isExternalField, "Outside of Organization", FieldTypes.Checkbox, orgUnitTypeDto.IsOutsideOfOrganization)); fields.Add(new Field(_siteIndicatorField, "Designates a Site Root", FieldTypes.Checkbox, orgUnitTypeDto.SiteIndicator)); fields.Add(new Field(_imageUrlField, "Image URL", FieldTypes.Text, orgUnitTypeDto.ImageUrl)); if (isReservedLocationType) { //Disable all fields fields.ForEach(f => f.IsDisabled = true); } return fields; }
private static bool CheckForReservedLocationTypes(OrgUnitTypeDto orgUnitTypeDto) { //We do not allow the user to edit the location types of "Site" or "PrintableProviderDirectory" return string.Equals(orgUnitTypeDto.Name, Constants.Locations.LocationTypePrintableProviderDirectory, StringComparison.InvariantCultureIgnoreCase) || string.Equals(orgUnitTypeDto.Name, Constants.Locations.LocationTypeSite, StringComparison.InvariantCultureIgnoreCase); }