public object GetValue() { if (this.Spinner.SelectedItemPosition != 0) { var selectedPosition = this.Spinner.SelectedItemPosition; var value = new DropdownValue <string>(this.Items[selectedPosition].Value); return(value); } return(null); }
public UIView GetView(IDictionary <string, object> inputCustomProperties, MyFormHandler myFormHandler) { this.PickerView = new UIPickerView(); this.Items = inputCustomProperties.GetCustomProperty <IList <DropdownItem> >("items"); this.Items.Insert(0, new DropdownItem { Label = "", Value = "" }); PickerModel model = new PickerModel(this.Items.Select(a => a.Label).ToArray()); model.PickerChanged += (sender, e) => { var selected = this.Items.SingleOrDefault(a => a.Label.Equals(e.SelectedValue)); var value = new DropdownValue <string>(selected?.Value); this.SelectedValue = value; }; this.PickerView.ShowSelectionIndicator = true; this.PickerView.Model = model; // Setup the toolbar UIToolbar toolbar = new UIToolbar { BarStyle = UIBarStyle.Black, Translucent = true }; toolbar.SizeToFit(); this.TextField = new UITextField(); this.TextField.Layer.CornerRadius = 8; this.TextField.Layer.BorderColor = UIColor.LightGray.CGColor; this.TextField.Layer.BorderWidth = 1; UIView paddingView = new UIView(new CGRect(0, 0, 10, 20)); this.TextField.LeftView = paddingView; this.TextField.LeftViewMode = UITextFieldViewMode.Always; // Create a 'done' button for the toolbar and add it to the toolbar UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.TextField.Text = this.SelectedValue.Value; this.TextField.ResignFirstResponder(); }); toolbar.SetItems(new [] { doneButton }, true); // Tell the textbox to use the picker for input this.TextField.InputView = this.PickerView; // Display the toolbar over the pickers this.TextField.InputAccessoryView = toolbar; return(this.TextField); }
public GetDropdownValueResponse GetDropdownValue(short dropDownValueId) { GetDropdownValueResponse response = new GetDropdownValueResponse(); DropdownValue dropdown = dropdownRepository.GetDropdownValue(dropDownValueId); if (dropdown == null) { response.Exception = GetDropdownvaluesNotFoundException(); } else { DropdownValueViewModel dropdownViewModel = Mapper.Map <DropdownValue, DropdownValueViewModel>(dropdown); response.DropdownValue = dropdownViewModel; } return(response); }
public async Task <int> SaveDropDownValue(DropdownDTO dto) { var returnId = 0; if (dto.Id > 0) { var existing = await _db.DropdownValue.Where(w => w.Id == dto.Id).FirstOrDefaultAsync(); if (existing != null) { existing.Active = dto.Active; existing.Value = dto.Name; existing.DropdownTypeId = dto.TypeId; await _db.SaveChangesAsync(); returnId = existing.Id; } } else { var existing = await _db.DropdownValue.FirstOrDefaultAsync(w => w.Value == dto.Name); if (existing != null) { existing.Active = dto.Active; existing.Value = dto.Name; existing.DropdownTypeId = dto.TypeId; await _db.SaveChangesAsync(); returnId = existing.Id; } else { var newDDVal = new DropdownValue { Active = dto.Active, Value = dto.Name, DropdownTypeId = dto.TypeId }; _db.DropdownValue.Add(newDDVal); await _db.SaveChangesAsync(); returnId = newDDVal.Id; } } return(returnId); }
public DropdownValue ProcessRow(SqlDataReader read, params DropdownValue.LazyComponents[] lazyComponents) { DropdownValue value = new DropdownValue(); value.Id = Convert.ToInt32(read["a.Id"]); value.Category.Id = Convert.ToInt32(read["a.CategoryId"].ToString()); value.Label = read["a.Label"].ToString(); value.OtherFlag = Convert.ToChar(read["a.OtherFlag"].ToString()); value.Description = read["a.Description"].ToString(); if (read["a.Concentration"].ToString() != "") value.Concentration = Convert.ToDecimal(read["a.Concentration"].ToString()); if (read["a.MaxDosage"].ToString() != "") value.MaxDosage = Convert.ToDecimal(read["a.MaxDosage"].ToString()); foreach (DropdownValue.LazyComponents a in lazyComponents) { if (a == DropdownValue.LazyComponents.LOAD_DROPDOWN_CATEGORY) { value.Category.ShortName = read["b.ShortName"].ToString(); value.Category.LongName = read["b.LongName"].ToString(); } } return value; }