public async Task <IActionResult> Edit(int id, [Bind("Id,Goal,Amount,Monthly")] NewGoal newGoal) { if (id != newGoal.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(newGoal); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewGoalExists(newGoal.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(newGoal)); }
protected override void Given() { _id = Guid.Empty; var game = new Game(_id); var foreignTeamCode = "FCB"; game.AddLocalTeam("RMD"); game.AddForeignTeam(foreignTeamCode); var startedOn = new DateTime(2021, 02, 01); game.Start(startedOn); _gamesRepositoryMock = new Mock <IGamesRepository>(); _gamesRepositoryMock .Setup(x => x.GetGame(_id)) .Returns(game); var gamesRepository = _gamesRepositoryMock.Object; var dateTimeServiceMock = new Mock <IDateTimeService>(); dateTimeServiceMock .Setup(x => x.GetUtcNow()) .Returns(startedOn.AddHours(2)); var dateTimeService = dateTimeServiceMock.Object; _sut = new GamesCommandService(gamesRepository, dateTimeService); _scorer = "Leo Messi"; _newGoal = new NewGoal { ScoredBy = _scorer, TeamCode = foreignTeamCode }; }
public string Get(string code) { try { NewGoal x = GetGoal(code); string json = JsonConvert.SerializeObject(x, Formatting.None); return(json); } catch (Exception e) { return("Error: " + e); } }
public async Task <IActionResult> Create([Bind("Id,Goal,Amount,Monthly")] NewGoal newGoal) { if (ModelState.IsValid) { _context.Add(newGoal); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(newGoal)); }
public string Get(string code) { NewGoal x = new NewGoal(); try { x = GetGoal(code); return(JsonConvert.SerializeObject(x, Formatting.None)); } catch (Exception e) { L.SendErrorLog(e, code, null, "Goals", "Get"); return(JsonConvert.SerializeObject(x, Formatting.None)); } }
public void AddGoal(Guid id, NewGoal newGoal) { var game = _gamesRepository.GetGame(id);//obtenemos el partido mediante la id GameToGameReportMapper mapeador = new GameToGameReportMapper(); GameReport report = mapeador.Map(game); ReporteGoles reporteGoles = new ReporteGoles(report); var currentDate = _dateTimeService.GetUtcNow(); //establecemos la fecha actual del partido var teamCode = newGoal.TeamCode; //obtenemos el nombre del equipo var goal = new Goal(currentDate, newGoal.ScoredBy); //creamos un goal con la fecha actual del gol //, y scoreby quien marco (nombre del jugador) var isTeamPlaying = game.LocalTeamCode == teamCode || game.ForeignTeamCode == teamCode; if (!isTeamPlaying)//si no esta jugando { throw new ResourceNotFoundException($"The team code {teamCode} is not playing the game"); } if (game.LocalTeamCode == teamCode) //si el juego el quipoLocal es igual al teamcode { game.AddLocalTeamGoal(goal); //agregamos al juego los goal que han marcado si pertenece a ese equipo // reporteGoles.añadirGoles(newGoal, goal); } else { game.AddForeignTeamGoal(goal);//se lo metemos al equipo adversario reporteGoles.añadirGoles(newGoal, goal); } _gamesRepository.UpdateGame(id, game);//actualizamos la base de datos con la id y game //actualizamos el reporte de la clase pivote mapeador = new GameToGameReportMapper(); Game juegoFinal = _gamesRepository.GetGame(id); GameReport reporteFinal = mapeador.Map(juegoFinal); reporteGoles = new ReporteGoles(report); _gamesRepository.AddReporteGoles(juegoFinal, reporteGoles); // }
public void añadirGoles(NewGoal newGoal, Goal gol) { //COMPROBAMOS si el gol que pasamos por parametros de de el equipo local o adversario if (newGoal.TeamCode.Equals(this.report.LocalTeamName)) { golesLocales.Add(gol); } else if (newGoal.TeamCode.Equals(this.report.ForeignTeamName)) { golesAdversario.Add(gol); } }
public NewGoal GetGoal(string code) { SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + dataBase)); connection.Open(); string sql = @"SELECT code, title FROM codeBook WHERE codeGroup = 'GOAL' AND code = @code"; SQLiteCommand command = new SQLiteCommand(sql, connection); command.Parameters.Add(new SQLiteParameter("code", code)); SQLiteDataReader reader = command.ExecuteReader(); NewGoal x = new NewGoal(); while (reader.Read()) { x.code = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0); x.title = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1); x.isDisabled = false; } connection.Close(); return(x); }
public List <NewGoal> GetGoals() { SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + dataBase)); connection.Open(); string sql = @"SELECT code, title FROM codeBook WHERE codeGroup = 'GOAL' ORDER BY codeOrder ASC"; SQLiteCommand command = new SQLiteCommand(sql, connection); List <NewGoal> xx = new List <NewGoal>(); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { NewGoal x = new NewGoal() { code = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0), title = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1), isDisabled = false }; xx.Add(x); } connection.Close(); return(xx); }
public void AddGoal(Guid id, NewGoal newGoal) { var game = _gamesRepository.GetGame(id); var currentDate = _dateTimeService.GetUtcNow(); var teamCode = newGoal.TeamCode; var goal = new Goal(currentDate, newGoal.ScoredBy); var isTeamPlaying = game.LocalTeamCode == teamCode || game.ForeignTeamCode == teamCode; if (!isTeamPlaying) { throw new ResourceNotFoundException($"The team code {teamCode} is not playing the game"); } if (game.LocalTeamCode == teamCode) { game.AddLocalTeamGoal(goal); } else { game.AddForeignTeamGoal(goal); } _gamesRepository.UpdateGame(id, game); }
public IActionResult AddGoal(Guid id, [FromBody] NewGoal newGoal) { _gamesCommandService.AddGoal(id, newGoal); return(Ok()); }
public bool conditionsToProceed(int stage) { bool answer = true; if (stage == 0) // The hand must be touchin point zero; { NewGoal newGoal = homePosition.GetComponent <NewGoal>(); answer = newGoal.handOnInitialPosition; if (!answer) { //personalNotifications.messageToUser("Be sure your hand is on the sphere"); personalNotifications.messageToUser("La mano en la esfera"); } } else if (stage == 1) { answer = (handLogic.possibleObject != null); // Implicit threshold lies in the size of both hand and objects if (!answer) { //personalNotifications.messageToUser("Be sure your hands is on the object. \n Do not move it"); personalNotifications.messageToUser("La mano sobre el objeto"); } } else if (stage == 2) { float threshold = 0.02f; PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>(); answer = propSpecs.distanceToDock() < threshold; if (!answer) { //notificationsMannager.messageToUser(@"It seems you are not in the final position"); personalNotifications.messageToUser("Que coincida el objeto y el fantasma"); } } else if (stage == 3) { NewGoal newGoal = homePosition2.GetComponent <NewGoal>(); answer = newGoal.handOnInitialPosition; if (!answer) { //notificationsMannager.messageToUser(@"It seems you are not in the final position"); personalNotifications.messageToUser("La mano sobre la esfera"); } } else if (stage == 4) { answer = (handLogic.possibleObject != null); if (!answer) { //notificationsMannager.messageToUser("Be sure your hand is on the sphere"); personalNotifications.messageToUser("La mano sobre el objeto"); } } else if (stage == 5) { float threshold = 0.02f; PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>(); answer = propSpecs.distanceToDock() < threshold; if (!answer) { //notificationsMannager.messageToUser("Be sure your hand is on the sphere"); personalNotifications.messageToUser("Que coincida el objeto y el fantasma"); } } else if (stage == 0) // The hand must be touchin point zero; { NewGoal newGoal = homePosition.GetComponent <NewGoal>(); answer = newGoal.handOnInitialPosition; if (!answer) { //personalNotifications.messageToUser("Be sure your hand is on the sphere"); personalNotifications.messageToUser("La mano en la esfera"); } } return(answer || testCond); }