public async Task <IActionResult> Add(InstrumentViewModel newInstrument) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } var currentUser = await _userManager.GetUserAsync(User); //newInstrument.AddedBy = _userManager.GetUserAsync(User).Id.ToString(); var instrument = new Instrument { FromName = newInstrument.FromName, ToName = newInstrument.ToName, FromCode = newInstrument.FromCode, ToCode = newInstrument.ToCode, Description = newInstrument.Description, AvailableFrom = newInstrument.AvailableFrom, ExpirationDate = newInstrument.ExpirationDate, AddedById = currentUser.Id }; var successful = await _instrumentService .AddInstrumentAsync(newInstrument); if (!successful) { return(BadRequest("Could not add instrument.")); } return(RedirectToAction("Index")); }
// private helper methods private ViewResult GetInstrument(int id, string operation) { var instrument = new InstrumentViewModel(); Load(instrument, operation, id); return(View("Instrument", instrument)); }
private void OpenComplexOrderWindow(InstrumentViewModel instrument) { ComplexOrderWindow cow = new ComplexOrderWindow(); cow.Owner = Application.Current.MainWindow; cow.ShowInstrument(instrument); }
private void Load(InstrumentViewModel vm, string op, int?id = null) { if (Operation.IsAdd(op)) { vm.Instrument = new Instrument(); } else { vm.Instrument = data.Instruments.Get(new QueryOptions <Instrument> { Includes = "InstrumentBrands.Brand, Department", Where = i => i.InstrumentId == (id ?? vm.Instrument.InstrumentId) }); } vm.SelectedBrands = vm.Instrument.InstrumentBrands?.Select( ib => ib.Brand.BrandId).ToArray(); vm.Brands = data.Brands.List(new QueryOptions <Brand> { OrderBy = b => b.BrandName }); vm.Departments = data.Departments.List(new QueryOptions <Department> { OrderBy = d => d.Name }); }
private void OpenNewChartWindow(InstrumentViewModel instrument) { ChartWindow tw = new ChartWindow(); tw.Owner = Application.Current.MainWindow; tw.ShowInstrument(instrument); //tw.Show(); }
public void ShowInstrument(InstrumentViewModel instrument) { var vm = DataContext as ComplexOrderWindowViewModel; vm.Instrument = instrument; vm.SelectedInstrument = instrument; Show(); }
public IActionResult Delete(InstrumentViewModel vm) { // no ModelState.IsValid check here bc there's no user input - // only BookId in hidden field is posted from form. data.Instruments.Delete(vm.Instrument); // cascading delete will get BookAuthors data.Save(); TempData["message"] = $"{vm.Instrument.Name} removed from Instruments."; return(RedirectToAction("Search")); // PRG pattern }
public IActionResult Instrument(int ID) { var instrument = GetInstrumentById(ID); var vm = new InstrumentViewModel { Instrument = instrument }; return(View(vm)); }
public void ShowInstrument(InstrumentViewModel instrument) { var vm = DataContext as SciChartPartViewModel; if (vm != null) { vm.Instrument = instrument; } Show(); }
private static InstrumentViewModel LoadInstrumentViewModel(int selectedId, List <string> msgs) { var model = new InstrumentViewModel { SelectedId = selectedId, Success = (msgs == null), ErrorMessages = msgs }; return(model); }
// GET: TalentByInstrument/Create public async Task <ActionResult> Create() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); InstrumentViewModel m = new InstrumentViewModel(); var instruments = _context.TalentByInstruments.Where(x => x.UserId == userId).ToList(); foreach (var i in instruments) { m.PlayedInstruments.Add(_context.Instruments.Where(x => x.InstrumentId == i.InstrumentId).FirstOrDefault()); } return(View(m)); }
public IActionResult Add() { var model = new InstrumentViewModel(); model.FromName = "Bitcoin"; model.ToName = "US Dollar"; model.FromCode = "BTC"; model.ToCode = "USD"; model.Description = " kryptowaluta wprowadzona w 2009 roku przez osobę o pseudonimie Satoshi Nakamoto. " + "Nazwa odnosi się także do używającego jej otwartoźródłowego oprogramowania oraz sieci peer-to-peer, którą formuje. "; model.AvailableFrom = DateTimeOffset.UtcNow; model.ExpirationDate = DateTimeOffset.UtcNow.AddDays(186); return(View(model)); }
public static void ShowInstrumentInfo(IInstrument instrument) { var w = new Window(); var vm = new InstrumentViewModel() { TargetObject = instrument }; var c = new InstrumentControl() { DataContext = vm }; w.Content = c; w.Title = instrument.Name; w.Show(); }
public ActionResult Edit(InstrumentViewModel viewModel) { if (ModelState.IsValid) { try { _instrumentService.Edit(viewModel.Id, viewModel.Manufacturer, viewModel.ModelNo, viewModel.Range, viewModel.Description, viewModel.CalibrationTime); return(RedirectToAction("Index")); } catch (DomainValidationException dex) { ModelState.UpdateFromDomain(dex.Result); } } return(PartialView("_Edit", viewModel)); }
void onDrop(List <IInstrument> dl) { var dc = DataContext as AnalyseProjectViewModel; dl.ForEach(v => { if (!dc.BlockList.Any(i => i.Ticker == v.Ticker)) { var iv = new InstrumentViewModel() { TargetObject = v.Clone() as IInstrument, GetCurrentDataSource = () => { return(dc.CurrentDataSource); } }; dc.BlockList.Add(iv); } }); }
public ActionResult Create(InstrumentViewModel viewModel) { if (ModelState.IsValid) { try { var id = Guid.NewGuid(); _instrumentService.Create(id, viewModel.Manufacturer, viewModel.ModelNo, viewModel.Range, viewModel.Description, viewModel.CalibrationTime); return(RedirectToAction("Index")); } catch (DomainValidationException dex) { ModelState.UpdateFromDomain(dex.Result); } } return(View(viewModel)); }
public IActionResult Add(InstrumentViewModel vm) { if (ModelState.IsValid) { data.AddNewInstrumentBrands(vm.Instrument, vm.SelectedBrands); data.Instruments.Insert(vm.Instrument); data.Save(); TempData["message"] = $"{vm.Instrument.Name} added to Instruments."; return(RedirectToAction("Index")); // PRG pattern } else { Load(vm, "Add"); return(View("Instrument", vm)); } }
public static void ShowInstrumentInfo(IInstrument instrument, Func <IDataSource> ds, DateTime start, DateTime end) { var w = new Window(); var vm = new InstrumentViewModel() { TargetObject = instrument, StartTime = start, EndTime = end, GetCurrentDataSource = ds }; var c = new InstrumentControl() { DataContext = vm }; vm.LoadMarketData(start, end, ds, instrument); w.Content = c; w.Title = instrument.Name; w.Show(); }
private void SelectedInstrumentChanged(object o) { InstrumentViewModel instrument = o as InstrumentViewModel; InstrumentTypeViewModel instrumentType = o as InstrumentTypeViewModel; _logger.Debug($"{GetType().Name}.{MethodBase.GetCurrentMethod().Name} - {instrumentType?.Type} - {instrument?.DisplayName}"); if (instrument != null) { SelectedInstrument = instrument; // Console.WriteLine(instrument.DisplayName); } if (instrumentType != null) { SelectedInstrument = null; // Console.WriteLine(instrumentType.Type); } }
public IActionResult Edit(InstrumentViewModel vm) { if (ModelState.IsValid) { data.DeleteCurrentInstrumentBrands(vm.Instrument); data.AddNewInstrumentBrands(vm.Instrument, vm.SelectedBrands); data.Instruments.Update(vm.Instrument); data.Save(); TempData["message"] = $"{vm.Instrument.Name} updated."; return(RedirectToAction("Search")); // PRG pattern } else { Load(vm, "Edit"); return(View("Instrument", vm)); } }
public static void ShowInstrumentInfo(string title, List <IMarketData> dataList) { var w = new Window(); var vm = new InstrumentViewModel() { IsEnableLoad = false, StartTime = dataList.Min(v => v.Time), EndTime = dataList.Max(v => v.Time) }; dataList.ForEach(v => vm.MarketDataList.Add(v)); var c = new InstrumentControl() { DataContext = vm }; w.Content = c; w.Title = title; w.Show(); }
public async Task <bool> AddInstrumentAsync(InstrumentViewModel newInstrument) { var instrument = new Instrument { Id = Guid.NewGuid(), FromName = newInstrument.FromName, FromCode = newInstrument.FromCode, ToName = newInstrument.ToName, ToCode = newInstrument.ToCode, AvailableFrom = newInstrument.AvailableFrom, Description = newInstrument.Description, ExpirationDate = newInstrument.ExpirationDate, AddedById = newInstrument.AddedBy }; _context.Instruments.Add(instrument); var saveResult = await _context.SaveChangesAsync(); return(saveResult == 1); }
public async Task <ActionResult> Create(InstrumentViewModel InstrumentData) { var talentByInstrument1 = new TalentByInstrument(); string UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); talentByInstrument1.UserId = UserId; talentByInstrument1.InstrumentId = InstrumentData.CreatedInstrument; _context.TalentByInstruments.Add(talentByInstrument1); await _context.SaveChangesAsync(); try { // TODO: Add insert logic here return(RedirectToAction("Create", "TalentByInstrument")); } catch { return(View()); } }
public InstrumentController(InstrumentViewModel instrumentViewModel) { _instrumentViewModel = instrumentViewModel; }
public BassController(InstrumentViewModel instrumentViewModel) : base(instrumentViewModel) { _tuning = new StandardBassTuning(); _instrumentViewModel.UpdateViewModel(_instrumentName, _tuning, _fretCount); }
public Instrument() { InitializeComponent(); DataContext = new InstrumentViewModel(); }
public GuitarController(IScaleListService dictionary, IModeDefinitionService scaleDirectoryService, InstrumentViewModel instrumentViewModel) : base(instrumentViewModel) { _tuning = new StandardGuitarTuning(); _instrumentViewModel.UpdateViewModel(_instrumentName, _tuning, _fretCount); }
public InstrumentPage() { InitializeComponent(); BindingContext = new InstrumentViewModel(); }