public TipView() { var zajednickiElementi = new ZajednickiElementiAplikacije(); BindingContext = new TipViewModel(); Title = "Tip vježbe"; var pitanjaButton = zajednickiElementi.PrimarniNavigacijskiButton("Generator pitanja"); pitanjaButton.SetBinding(Button.CommandProperty, nameof(TipViewModel.PitanjeCommand)); var korakButton = zajednickiElementi.PrimarniNavigacijskiButton("Korak po korak"); korakButton.SetBinding(Button.CommandProperty, nameof(TipViewModel.KorakCommand)); Content = new StackLayout { Children = { pitanjaButton, korakButton } , Margin = new Thickness(0, 10, 0, 0) }; }
private void zatvaranje(object sender, System.ComponentModel.CancelEventArgs e) { //kada kliknemo na odustani ovo ce se izvrsiti TipViewModel aa = (TipViewModel)DataContext; aa.OdustaniEditTipa(); }
public int UpdateTip(TipViewModel tip) { Tip old_tip = DAManager.TipsRepository.Get(t => t.TipId == tip.TipId).FirstOrDefault(); if (old_tip != null) { old_tip.CampaignId = tip.CampaignId; old_tip.Description = tip.Description; old_tip.IsPublished = tip.IsPublished; old_tip.OnlineDate = tip.OnlineDate; old_tip.TipId = tip.TipId; old_tip.Title = tip.Title; } else { return(-1); } try { DAManager.Save(); return(old_tip.TipId); } catch (Exception ex) { logService.WriteError(ex.Message, ex.Message, ex.StackTrace, ex.Source); return(-1); } }
public async Task <IActionResult> Tip(string id) { rest_api.Models.Tip tip = await TipViewManager.GetTipById(id); TipViewModel viewModel = new TipViewModel(tip); return(View(viewModel)); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { TipViewModel tipViewModel = value as TipViewModel; SearchStrategy strategy = tipViewModel.SearchStrategy; string searchString = tipViewModel.SearchString; return(Strategy.parseInput <string>(searchString, (first, inp) => strategy.tipMap.ContainsKey(first) && inp.Length == 1 ? first + strategy.tipMap[first] : "", AppResources.GeneralSearchTip)); }
private void Events_OnTip(string message) { TipControl = new TipViewModel(message); TipControl.RequestClose += () => { TipControl = null; NotifyOfPropertyChange(() => TipControl); }; NotifyOfPropertyChange(() => TipControl); }
public async Task TestThatWhenSubTotalChangeTipUpdate() { //Arrange var calculatorService = new CalculatorService(); //sut: System Under Test var sut = new TipViewModel(calculatorService); await sut.Initialize(); sut.SubTotal = 200; Assert.That(sut.Tip, Is.EqualTo(20)); }
public void TestCommand() { var vm = new TipViewModel(new CalculationService(), null); double originalSubTotal = 25; vm.SubTotal = originalSubTotal; vm.ClickCommand.Execute(); Assert.AreEqual(originalSubTotal * 10, vm.SubTotal); }
/// <summary> /// 行をクリックしたとき /// </summary> /// <param name="tableView"></param> /// <param name="indexPath"></param> public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var data = new MyData(); switch (indexPath.Row) { case 0: /// MVVM を使わずに Xamarin.iOS + storyboard だけ使うパターン /// あらかじめ storyboard segue でつなげておく data.PageNum = 1; data.Name = "Xamarin.iOS only"; break; case 1: /// MvvmCross を使って vm 経由でデータを渡す /// 本来は data 経由のほうがいいけど、これはサンプルで /// あらかじめ storyboard segue でつなげておく _datavm = new TipViewModel() { PageNum = 2, Name = "use MvvmCross" }; break; case 2: /// storyboard のページを直接開く /// Storyboard ID を ViewController に設定しておく /// storyboard segue を使わないパターン var vc = (Detail3ViewController)Storyboard.InstantiateViewController("Detail3ViewController"); this.NavigationController.ShowViewController(vc, this); _datavm2 = new TipViewModel2() { PageNum = 3, Name = "Mvx + direct storyboard" }; break; case 3: // Xamarin.Forms ページを開く var page = MvxXForms.Form.App.GetDetailPage(); var vc2 = page.CreateViewController(); var vm = new TipViewModel() { PageNum = 4, Name = "xamarin froms page" }; page.BindingContext = vm; this.NavigationController.ShowViewController(vc2, this); break; } _data = data; }
public void BogusCalculationServiceTest() { var calcSvc = new CalculationService(); var vm = new TipViewModel(calcSvc, null); vm.SubTotal = 1234; vm.Generosity = 10; var actual = vm.Tip; var expected = 123.4; Assert.AreEqual(expected, actual, "Expected tip amount does not match."); }
// //GET: /Admin/AdminTip/Edit/{category-id} public ActionResult Edit(int id) { ViewBag.SelectedPage = Navigator.Items.TIPS; TipViewModel tip = servicesManager.TipService.GetTipById(id); FillTipsCampaigns(tip.CampaignId); if (tip == null) { return(RedirectToAction("List")); } return(View(tip)); }
public override void ViewDidLoad() { this.Request = new MvxViewModelRequest(typeof(TipViewModel), null, null, new MvxRequestedBy()); base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. var set = this.CreateBindingSet <Detail2ViewController, TipViewModel>(); set.Bind(labelPageNum).To(vm => vm.PageNum); set.Bind(labelName).To(vm => vm.Name); set.Apply(); // マスターからのデータ引き渡し this.ViewModel = MasterViewController._datavm; }
public async Task <IActionResult> ShowPredictionsByTip(int TipTypeId, int TipId) { TipViewModel tVM = new TipViewModel { Tip = await tipRepository.GetTipByTipId(TipId), Predictions = await repository.GetPredictionsByTipId(TipId), TipStats = await repository.GetTipStatsByTipId(TipId), LeagueStats = await repository.GetLeagueStatsByTip(TipId), ControllerName = "Statistics", TipTypeId = TipTypeId }; ViewData["TipTypeId"] = TipTypeId; return(View("Tip", tVM)); }
public ActionResult Edit(TipViewModel model) { var tip = db.Tips.FirstOrDefault(h => h.ID == model.ID); if (tip == null) { throw new Exception("Tip not found."); } //Repace the Tip with the edited Tip db.Tips.Remove(tip); db.Tips.Add(Casting.UpCast <Tip, TipViewModel>(model)); //the upcast prevents all the extra stuff from being saved db.Save(); db = DotADB.Load(); return(Index()); }
public void TestThatWhenGenerosityChangesTipIsRecalculated() { //Arrange var mockTipService = new Mock <ICalculation>(); mockTipService.Setup(t => t.TipAmount(It.IsAny <double>(), It.IsAny <int>())) .Returns(37.0); //Act var tipViewModel = new TipViewModel(mockTipService.Object) { Generosity = 12 }; //Assert Assert.AreEqual(37.0, tipViewModel.Tip); }
public void TestThatWhenSubTotalChangesTipIsRecalculated() { //Arrange base.ClearAll(); var mockTipService = new Mock <ICalculation>(); mockTipService.Setup(t => t.TipAmount(It.IsAny <double>(), It.IsAny <int>())) .Returns(42.0); //Act var tipViewModel = new TipViewModel(mockTipService.Object) { SubTotal = 12 }; //Assert Assert.AreEqual(42.0, tipViewModel.Tip); }
public ActionResult Create(TipViewModel model, bool returnToHeroList = false) { if (db.Tips.Any(h => h.ID == model.ID)) { throw new Exception("Tip ID collision"); } db.Tips.Add(Casting.UpCast <Tip, TipViewModel>(model)); db.Save(); if (!returnToHeroList) { return(Index()); } TempData["SelectedHeroID"] = model.HeroID; return(RedirectToAction("Index", "Hero", new { })); }
public TipViewModel GetTipById(int tip_id) { var tip = DAManager.TipsRepository.Get(t => t.TipId == tip_id).FirstOrDefault(); if (tip != null) { TipViewModel tip_viewmodel = new TipViewModel() { CampaignId = tip.CampaignId, Description = tip.Description, IsPublished = tip.IsPublished, OnlineDate = tip.OnlineDate, Title = tip.Title, TipId = tip.TipId }; return(tip_viewmodel); } else { return(null); } }
public void AddDrinksIncreasesSubtotalBy10x() { base.Setup(); var calcSvcMock = new Mock <ICalculationService>(); calcSvcMock.Setup(m => m.TipAmount(It.IsAny <double>(), It.IsAny <int>())).Returns(4); var vm = new TipViewModel(calcSvcMock.Object, null); var origSubtotal = 50; vm.SubTotal = origSubtotal; vm.ClickCommand2.Execute(this); var newSubTotal = vm.SubTotal; Assert.AreEqual(origSubtotal * 10, newSubTotal); }
public ActionResult Edit(TipViewModel tip) { ViewBag.SelectedPage = Navigator.Items.TIPS; if (ModelState.IsValid) { int new_id = servicesManager.TipService.UpdateTip(tip); if (new_id > 0) { TempData["SuccessMessage"] = "Tip Updated Successfully"; return(RedirectToAction("Edit", tip.TipId)); } else { TempData["ErrorMessage"] = "Tip Failed To Update"; } } FillTipsCampaigns(tip.CampaignId); return(View(tip)); }
// GET: Tip/Create /// <summary> /// /// </summary> /// <param name="heroID"></param> /// <param name="requestOrigin"></param> /// <returns></returns> public ActionResult Create(int heroID = -1, bool returnToHeroList = false) { ViewBag.ReturnToHeroList = returnToHeroList; var heroOptions = GetHeroOptions(heroID); var tvm = new TipViewModel() { Patch = db.CurrentPatch, HeroOptions = heroOptions }; if (heroID != -1) { tvm.HeroID = heroID; } if (db.Tips.Count() > 0) { tvm.ID = db.Tips.Max(h => h.ID) + 1; } return(View("Create", tvm)); }
public int AddNewTip(TipViewModel tip) { Tip db_tip = new Tip() { AddedDate = DateTime.Now, CampaignId = tip.CampaignId, Description = tip.Description, IsPublished = tip.IsPublished, OnlineDate = tip.OnlineDate, Title = tip.Title }; DAManager.TipsRepository.Insert(db_tip); try { DAManager.Save(); } catch (Exception ex) { logService.WriteError(ex.Message, ex.Message, ex.StackTrace, ex.Source); return(-1); } return(db_tip.TipId); }
public void TestThatWhenTipIsRecalculatedThenTipNotificationIsSent() { //Arrange var mockTipService = new Mock <ICalculation>(); mockTipService.Setup(t => t.TipAmount(It.IsAny <double>(), It.IsAny <int>())) .Returns(37.0); var tipViewModel = new TipViewModel(mockTipService.Object); var tipChangeCount = 0; var generosityChangeCount = 0; var subTotalCount = 0; tipViewModel.PropertyChanged += (sender, e) => { switch (e.PropertyName) { case "Tip": tipChangeCount++; break; case "SubTotal": subTotalCount++; break; case "Generosity": generosityChangeCount++; break; } }; //Act tipViewModel.Generosity = 12; //Assert Assert.AreEqual(1, tipChangeCount); Assert.AreEqual(0, subTotalCount); Assert.AreEqual(1, generosityChangeCount); }
public ActionResult New(TipViewModel tip) { ViewBag.SelectedPage = Navigator.Items.NEWTIP; FillTipsCampaigns(tip.CampaignId); if (ModelState.IsValid) { int new_id = servicesManager.TipService.AddNewTip(tip); if (new_id > 0) { TempData["SuccessMessage"] = "Tip Added Successfully"; return(RedirectToAction("Edit", new { id = new_id })); } else { TempData["ErrorMessage"] = "Tip Failed To Add"; } } return(View(tip)); }
public void TestThatPayCommandShowsPayViewModelWithCorrectTotal() { //Arrange var mockTipService = new Mock <ICalculation>(); mockTipService.Setup(t => t.TipAmount(It.IsAny <double>(), It.IsAny <int>())) .Returns(19); var tipViewModel = new TipViewModel(mockTipService.Object) { Generosity = 12, SubTotal = 10 }; //act tipViewModel.PayComamnd.Execute(null); //Assert Assert.AreEqual(1, MockDispatcher.Requests.Count); var request = MockDispatcher.Requests[0]; Assert.AreEqual(typeof(PayViewModel), request.ViewModelType); Assert.AreEqual("29", request.ParameterValues["total"]); }
public TipPage() { BindingContext = new TipViewModel(); InitializeComponent(); }
public Window1() { InitializeComponent(); DataContext = new TipViewModel(); }
public RemoveTipCommand(TipViewModel viewModel) { _ViewModel = viewModel; }
public AddTipCommand(TipViewModel viewModel) { _ViewModel = viewModel; }
public PonistiPretragu(TipViewModel viewModel) { _ViewModel = viewModel; }