public IActionResult PutPlayers(int id, Players players)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != players.PlayerId)
            {
                return(BadRequest());
            }

            _dystirDBContext.Entry(players).State = EntityState.Modified;

            try
            {
                _dystirDBContext.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlayersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(StatusCodes.Status204NoContent));
        }
        public IActionResult PutSponsors(int id, Sponsors sponsors)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sponsors.Id)
            {
                return(BadRequest());
            }

            db.Entry(sponsors).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SponsorsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(StatusCodes.Status204NoContent));
        }
        public IActionResult PutPlayersOfMatches([FromQuery] int id, PlayersOfMatches playersOfMatches)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != playersOfMatches.PlayerOfMatchId)
            {
                return(BadRequest());
            }

            _dystirDBContext.Entry(playersOfMatches).State = EntityState.Modified;

            try
            {
                _dystirDBContext.SaveChanges();
                Matches match = _dystirDBContext.Matches.FirstOrDefault(x => x.MatchID == playersOfMatches.MatchId);
                HubSend(match);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlayersOfMatchesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(StatusCode(StatusCodes.Status204NoContent));
        }
Exemple #4
0
        public IActionResult PutMatches(int id, [FromBody] Matches matches)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != matches.MatchId)
            {
                return(BadRequest());
            }
            try
            {
                Matches matchInDB = db.Matches.Find(id);
                if (!(matches.ExtraMinutes == 0 && matches.ExtraSeconds == 0) || matchInDB.StatusId != matches.StatusId)
                {
                    matches.StatusTime = DateTime.UtcNow.AddMinutes(-matches.ExtraMinutes).AddSeconds(-matches.ExtraSeconds);
                }

                db.Entry(matchInDB).CurrentValues.SetValues(matches);
                db.Entry(matchInDB).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MatchesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            HubSend(matches);

            return(StatusCode(StatusCodes.Status204NoContent));
        }
Exemple #5
0
        public IActionResult PutEventsOfMatches(int id, EventsOfMatches eventsOfMatches)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != eventsOfMatches?.EventOfMatchId)
            {
                return(BadRequest());
            }
            try
            {
                if (eventsOfMatches.EventName != null)
                {
                    _dystirDBContext.Entry(eventsOfMatches).State = EntityState.Modified;
                    RemoveSecondEvent(eventsOfMatches);
                    string sendingText = eventsOfMatches.EventText;
                    eventsOfMatches.EventMinute = GetEventMinute(eventsOfMatches);
                    CreateTextOfEvent(eventsOfMatches);
                    _dystirDBContext.SaveChanges();
                    AddSecondEvent(sendingText, eventsOfMatches);
                    SetNewEventsList((int)eventsOfMatches.MatchId);
                    Matches match = _dystirDBContext.Matches.FirstOrDefault(x => x.MatchID == eventsOfMatches.MatchId);
                    HubSend(match);
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventsOfMatchesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }