public async Task <IActionResult> Edit(int id, [Bind("TipsterId,Name,Email,PhoneNumber")] Tipster tipster) { if (id != tipster.TipsterId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipster); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipsterExists(tipster.TipsterId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipster)); }
private void button1_Click(object sender, RoutedEventArgs e) { Tipster tipster = new Tipster() { FirstName = this.firstName.Text, Surname = this.Surname.Text, emailAddress = this.Email.Text, InitialScore = Int32.Parse(this.InitialScore.Text) }; (Application.Current as App).Comp.Tipsters.Add(tipster); this.Close(); }
public async Task <IActionResult> Create([Bind("TipsterId,Name,Email,PhoneNumber")] Tipster tipster) { try { if (ModelState.IsValid) { _context.Add(tipster); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(tipster)); }
static void RunTest() { TippingCompetition comp = new TippingCompetition(); // Create new Season Season season = comp.Season; GrandPrix Melbourne; GrandPrix KL; season.Races.Add(Melbourne = new GrandPrix() { Location = "Australian" }); season.Races.Add(KL = new GrandPrix() { Location = "Malaysian" }); season.Races.Add(new GrandPrix() { Location = "Chinese" }); season.Races.Add(new GrandPrix() { Location = "Bahrain" }); Driver Webber; Driver Vettel; Driver Kimi; season.Drivers.Add(Webber = new Driver() { Name = "Mark Webber", TeamName = "Red Bull" }); season.Drivers.Add(Vettel = new Driver() { Name = "Sebastian Vettel", TeamName = "Red Bull" }); season.Drivers.Add(Kimi = new Driver() { Name = "Kimi Raikkonen", TeamName = "Lotus" }); Tipster Matt; Tipster Dave; Tipster Hanky; comp.Tipsters.Add(Matt = new Tipster() { FirstName = "Matt", Surname = "Nicholls" }); comp.Tipsters.Add(Dave = new Tipster() { FirstName = "David", Surname = "Mutch" }); comp.Tipsters.Add(Hanky = new Tipster() { FirstName = "Daniel", Surname = "Hancock" }); //Matt.Tips.Add(Melbourne, new Tip() { Qualifying = Webber, Race = Webber }); //Dave.Tips.Add(Melbourne, new Tip() { Qualifying = Kimi, Race = Vettel }); //Hanky.Tips.Add(Melbourne, new Tip() { Qualifying = Vettel, Race = Webber }); //Matt.Tips.Add(KL, new Tip() { Qualifying = Webber, Race = Webber }); //Dave.Tips.Add(KL, new Tip() { Qualifying = Kimi, Race = Vettel }); ////Hanky.Tips.Add(KL, new Tip() { Qualifying = Vettel, Race = Webber }); comp.AddTip(Matt, Melbourne, new Tip() { Qualifying = Webber, Race = Webber }); comp.AddTip(Dave, Melbourne, new Tip() { Qualifying = Kimi, Race = Vettel }); comp.AddTip(Hanky, Melbourne, new Tip() { Qualifying = Vettel, Race = Webber }); comp.AddTip(Matt, KL, new Tip() { Qualifying = Webber, Race = Vettel }); comp.AddTip(Dave, KL, new Tip() { Qualifying = Kimi, Race = Vettel }); Melbourne.QualifyingResults.Add(Webber); Melbourne.QualifyingResults.Add(Kimi); Melbourne.QualifyingResults.Add(Vettel); Melbourne.RaceResults.Add(Kimi); Melbourne.RaceResults.Add(Vettel); Melbourne.RaceResults.Add(Webber); KL.QualifyingResults.Add(Vettel); KL.QualifyingResults.Add(Webber); KL.QualifyingResults.Add(Kimi); KL.RaceResults.Add(Vettel); KL.RaceResults.Add(Webber); KL.RaceResults.Add(Kimi); comp.GenerateScores(); PersistTippingComp(comp); comp = null; comp = DeserializeTippingCompFile(comp); comp.GenerateScores(); Console.Write(comp.BuildLeaderTable()); Console.ReadLine(); }
public void Constructor_ShouldPass_WithValidParams() { var tipster = new Tipster(this.name, this.company); Assert.IsInstanceOf <Tipster>(tipster); }