public async override Task ValidateAsync(DemoViewModel model, ModelStateDictionary state) { if (await this.service.CheckSomethingAsync(model)) { state.AddModelError(nameof(model.SomeProperty), $"Whoops!!!"); } }
public PickerSpecific() { InitializeComponent(); BindingContext = new DemoViewModel(); Title = "Picker - Platform Specifics"; }
public ActionResult Index(string text) { var getText = _demoServiceFacade.GetText(text); var settings = _settingsServiceFacade.GetSettings(); var samplesettings = _settingsServiceFacade.GetSampleSettings(); if (getText != null) { var demo = new DemoViewModel { Match = getText.Match, Settings = settings, SampleSettings = samplesettings }; if (getText.EditFound) { return(View(demo)); } } else { return(View()); } var demo1 = new DemoViewModel { Match = getText.Match, Settings = settings, SampleSettings = samplesettings }; return(getText.TextToUseFound ? Index(demo1) : View()); }
public PickerCustom() { InitializeComponent(); BindingContext = new DemoViewModel(); Title = "Picker - Custom Renderer"; }
public void WhenArgumentIsNotNull_ShouldSetProperty() { var result = Math.PI; var model = new DemoViewModel <double>(result); Assert.Equal(result, model.Model); }
public PickerStandard() { InitializeComponent(); BindingContext = new DemoViewModel(); Title = "Picker"; }
public MainWindow() { InitializeComponent(); // View first for simplicity of demo. //DataContext = new DemoViewModel(); DataContext = new DemoViewModel(); }
public void WhenProtectedSetterUsed_ShouldGetEqualValue() { var model = new DemoViewModel <int>(1); model.PropertySetter(-100); Assert.Equal(-100, model.Model); }
public ActionResult Index() { var searchResult = _searchResultRepository.GetSearchResult(new SearchCriteria()); var viewModel = new DemoViewModel(searchResult.TotalSearchResults, searchResult.Hits); return(View(viewModel)); }
public ActionResult GetTaxonomyPickerHiddenValue(DemoViewModel model) { if (!ModelState.IsValid) //Check for validation errors { RedirectToAction("Index", "Home"); } return(Json(JsonHelper.Serialize <DemoViewModel>(model), JsonRequestBehavior.AllowGet)); }
public IActionResult Partial2() { var usernames = this.usersService.GetUsernames().ToList(); var viewModel = new DemoViewModel { Usernames = usernames }; return(this.View(viewModel)); }
public MainWindow() { InitializeComponent(); viewModel1 = new DemoViewModel("1"); viewModel2 = new DemoViewModel("2"); view1.DataContext = viewModel1; view2.DataContext = viewModel2; }
public DemoWindow() { InitializeComponent(); //设置表格内容 table.Loaded += Table_Loaded; //设置数据源、分页事件 demoViewModel = new DemoViewModel(10, 1); table.DataContext = demoViewModel; }
public ActionResult Gauge() { LimpiarSession(); DemoViewModel model = new DemoViewModel(); model.Titulo = "Dashboard"; ViewBag.Titulo = model.Titulo; return(View(model)); }
public ActionResult Save(DemoViewModel viewModel) { // POST-save-redirect-GET pattern. // Not a best practice but leads to cleaner controllers. // Also cleaner UX: no form resubmission warnings. // The model binder already populated the DemoViewModel for us, which did the "save" (it saved the favourite colours to the static variable). // We might do some extra work in a more complex secenario. // eg. viewModel.SaveToId(Session["id"]) return(RedirectToAction("Index")); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindow"/> class. /// </summary> public MainWindow() { // Set viewmodel _vm = new DemoViewModel(); // Set data context this.DataContext = _vm; // Initialize UI InitializeComponent(); }
public ActionResult Defer(FormCollection Form) { DemoViewModel item = new DemoViewModel(); if (TryUpdateModel <DemoViewModel>(item)) { return(RedirectToAction("Defer")); } return(View(item)); }
public async Task <ActionResult> Demo(string tenantId, string groupId) { GraphServiceClient graphClient = await GetAuthenticatedClient(tenantId); var viewModel = new DemoViewModel() { Channels = await GetChannelsList(graphClient, tenantId, groupId), Permissions = await GetPermissionGrants(graphClient, tenantId, groupId) }; return(View(viewModel)); }
public async Task Save(DemoViewModel model, bool update = false) { if (!update) { var command = _mapper.Map <AddDemoCommand>(model); await _mediator.SendCommand(command); } else { var command = _mapper.Map <UpdateDemoCommand>(model); await _mediator.SendCommand(command); } }
public DemoViewModel Update([FromBody] DemoViewModel demo) { var entity = _demos.FirstOrDefault(x => x.Id == demo.Id); if (entity == null) { return(demo); } entity.Name = demo.Name; entity.Price = demo.Price; return(demo); }
public DemoPresenter ( DemoViewModel viewModel, IncreaseRequestedSignal increaseRequestedSignal, DecreaseRequestedSignal decreaseRequestedSignal ) { _viewModel = viewModel; _increaseRequestedSignal = increaseRequestedSignal; _decreaseRequestedSignal = decreaseRequestedSignal; _point = 0; }
public ActionResult Index(DemoViewModel viewModel) { _settingsServiceFacade.UpdateSettings(viewModel.Settings, viewModel.SampleSettings); var getmatch = _demoServiceFacade.GetMatchFor(viewModel.Match); if (getmatch.MatchesSuccessfullyFound) { return(RedirectToAction(getmatch.MenuType)); } // no match - display for edit ViewBag.ErrorMessage = getmatch.Message; return(View(viewModel)); }
public ActionResult Login() { var model = new DemoViewModel(); if (TryUpdateModel(model)) { SendEmail("Demo Login [" + Request.UserHostAddress + "]", model.Email); FormsAuthentication.SetAuthCookie("admin", false); return(Redirect(CurrentPage.Url)); } TempData["Deferred"] = true; TempData["DeferredModel"] = model; TempData["DeferredState"] = ModelState; return(RedirectToParentPage()); }
// Start is called before the first frame update void Start() { m_ViewModel = new DemoViewModel(); m_ViewModel.Str.Subscribe(str => { m_TxtValue.text = str; }); m_InputField.onValueChanged.AddListener(str => { Debug.LogError("onValueChanged"); m_ViewModel.Str.Value = str; }); // m_InputField.OnValueChangedAsObservable().Subscribe(str => // { // m_ViewModel.Str.Value = str; // }); // }
public IActionResult Hacks() { DemoViewModel model = new DemoViewModel { Year = DateTime.UtcNow.Year, Products = new List <string>() }; if (DateTime.UtcNow.Minute % 2 == 0) { model.Products = new List <string> { "Eggs", "Milk", "Cucumbers" }; } ; return(View(model)); }
public IActionResult Demo(DemoViewModel model) { var watch = Stopwatch.StartNew(); var ua = YauaaSingleton.Analyzer.Parse(model.UserAgent); model.Version = Utils.YauaaVersion.GetVersion(); var fieldNames = ua.GetAvailableFieldNames(); model.Fields = new Dictionary <string, AgentField>(); foreach (var name in fieldNames) { model.Fields[name] = ua.Get(name); } watch.Stop(); var seconds = watch.ElapsedTicks / (double)Stopwatch.Frequency; if (seconds < 1) { var ms = seconds * 1000; if (ms < 1) { var us = ms * 1000; if (us < 1) { var ns = us * 1000; model.ElapsedTime = $"{ns} ns"; } else { model.ElapsedTime = $"{us} µs"; } } else { model.ElapsedTime = $"{ms} ms"; } } else { model.ElapsedTime = $"{seconds} s"; } return(this.View(model)); }
// GET: Demo public ActionResult Index() { DemoViewModel vm = new DemoViewModel() { Countries = new List <SelectListItem>() }; var query = from country in DbContext.Countries select new SelectListItem { Text = country.CountryName, Value = country.CountryId.ToString() }; foreach (var item in query) { vm.Countries.Add(item); } return(View(vm)); }
public ContentResult GetEncryptedJson( [Bind(Prefix = "payload")] DemoViewModel model, string environment) { var payload = M2uPaymentGateway.CreatePayload( model.Amount, model.AccountNo, model.PayeeCode, model.RefNo); var isValidEnvironment = Enum.TryParse( environment, out M2uPaymentGateway.Environment targetEnvironment); var encryptedJson = payload.GetEncryptionJsonString( isValidEnvironment ? (int)targetEnvironment : Convert.ToInt32(environment)); return(Content(encryptedJson, "application/json")); }
public ActionResult GetCities(int?stateId) { DemoViewModel vm = new DemoViewModel() { Cities = new List <SelectListItem>() }; var query = from city in DbContext.Cities where city.StateId == stateId.Value select new SelectListItem { Text = city.CityName, Value = city.CityId.ToString() }; foreach (var item in query) { vm.Cities.Add(item); } return(Json(vm, JsonRequestBehavior.AllowGet)); }
public ActionResult GetStates(int?countryId) { DemoViewModel vm = new DemoViewModel() { States = new List <SelectListItem>() }; if (countryId.HasValue) { var query = from state in DbContext.States where state.CountryId == countryId.Value select new SelectListItem { Text = state.StateName, Value = state.StateId.ToString() }; foreach (var item in query) { vm.States.Add(item); } } return(Json(vm, JsonRequestBehavior.AllowGet)); }