private void UpdateFromModel(Model.Models.Tournament tournament) { //Set values _name = tournament.Name; _startDate = tournament.StartTime ?? DateTime.Now; _description = tournament.Description; _maximumMatchDururationInMinutes = tournament.MatchDuration ?? 30; _teamCount = Model.TeamCount ?? 16; //Raise property changed for values RaisePropertyChanged(() => Name); RaisePropertyChanged(() => Description); RaisePropertyChanged(() => MaximumMatchDurationInMinutes); RaisePropertyChanged(() => TeamCount); //Raise property changed for calculated values RaisePropertyChanged(() => StartDate); RaisePropertyChanged(() => StartTime); RaisePropertyChanged(() => State); RaisePropertyChanged(() => FinalMatch); RaisePropertyChanged(() => Matches); RaisePropertyChanged(() => HasChanges); RaisePropertyChanged(() => TournamentEditable); //Raise property changed for commands SaveChangesCommand.RaiseCanExecuteChanged(); StartCommand.RaiseCanExecuteChanged(); AddTeamCommand.RaiseCanExecuteChanged(); RemoveTeamCommand.RaiseCanExecuteChanged(); AddPlayAreaCommand.RaiseCanExecuteChanged(); RemovePlayAreaCommand.RaiseCanExecuteChanged(); GenerateWinnerCertificatesCommand.RaiseCanExecuteChanged(); }
public async Task <IActionResult> AddTeam([FromBody] AddTeamCommand command) { if (command is null) { return(BadRequest()); } var teamId = await _mediator.Send(command); return(CreatedAtAction("AddTeam", new { id = teamId })); }
public async Task AddTeamCommand_Can_Add_Team() { using (var dbContext = GetDbContext("AddTeamCommand_Can_Add_Team")) { var fakeRepo = new PlayerRepository(dbContext); await fakeRepo.AddAsync(new Domain.Entities.Player { Name = "FirstPlayer", Surname = "LastName", Height = 1.98, EmailAddress = "*****@*****.**" }); await fakeRepo.AddAsync(new Domain.Entities.Player { Name = "SecondPlayer", Surname = "LastName", Height = 1.98, EmailAddress = "*****@*****.**" }); } using (var dbContext = GetDbContext("AddTeamCommand_Can_Add_Team")) { var fakeTeamRepo = new TeamRepository(dbContext); var fakePlayerRepo = new PlayerRepository(dbContext); var fakeLogger = new Mock <ILogger <AddTeamCommandHandler> >(); var handler = new AddTeamCommandHandler(fakeTeamRepo, fakePlayerRepo, GetMapper(), fakeLogger.Object); var command = new AddTeamCommand { Name = "TestTeamName", Longitude = 8.11, Latitude = 9.43, PlayerIds = new List <int> { 1, 2 } }; var result = await handler.Handle(command, default); Assert.False(result.Notifications.HasErrors()); Assert.Equal(command.Name, result.TeamLookupModel.Name); Assert.Equal(command.Latitude, result.TeamLookupModel.Latitude); Assert.Equal(command.Longitude, result.TeamLookupModel.Longitude); Assert.Equal(command.PlayerIds.ToList()[0], result.TeamLookupModel.Players.ToList()[0].Id); Assert.Equal(command.PlayerIds.ToList()[1], result.TeamLookupModel.Players.ToList()[1].Id); } }
public ActionResult Add(AddTeamCommand command) { if (ModelState.IsValid) { logger.InfoFormat("Add Save {0}", command.Name); _addTeamCommand.Handle(command); return(RedirectToAction("Index")); } var model = GetAddData(); model.Command = command; return(View(model)); }
public async Task <ActionResult <TeamViewModel> > Add([FromBody] AddTeamCommand addTeamCommand) { return(ResolveResult(await Mediator.Send(addTeamCommand))); }