public async Task <IActionResult> PutMatch(int id, Match match) { if (id != match.MatchID) { return(BadRequest()); } _context.Entry(match).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MatchExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutChampionship(int id, Championship championship) { if (id != championship.ID) { return(BadRequest()); } _context.Entry(championship).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChampionshipExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPlayer(int id, Player player) { if (id != player.ID) { return(BadRequest()); } _context.Entry(player).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Player> > PostTodoItem(Player players) { _context.Player.Add(players); await _context.SaveChangesAsync(); //return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem); return(CreatedAtAction(nameof(GetRepositories), new { id = players.PlayerId }, players)); }
public async Task <IActionResult> Create([Bind("Id,Name,Email,Password,Member1,Member2,Member3,Member4,Member5,Member6,Member7,Member8,Member9,Member10")] UserType user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("ID,Age,LastName,FirstName,Command")] Player player) { if (ModelState.IsValid) { _context.Add(player); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(player)); }
public async Task <IActionResult> Create([Bind("CommandID,PlayerID,Country,Name")] Command command) { if (ModelState.IsValid) { _context.Add(command); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(command)); }
public async Task <IActionResult> Create([Bind("SponsorId,Name")] Sponsor sponsor) { if (ModelState.IsValid) { _context.Add(sponsor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sponsor)); }
public async Task <IActionResult> Create([Bind("Id,Name,ClubsNumber")] Cup cup) { if (ModelState.IsValid) { _context.Add(cup); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cup)); }
public async Task <IActionResult> Create([Bind("Id")] MapModel mapModel) { if (ModelState.IsValid) { _context.Add(mapModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(mapModel)); }
public async Task <IActionResult> Create([Bind("TeamId,TeamName,FoundationDate")] Team team) { if (ModelState.IsValid) { _context.Add(team); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(team)); }
public async Task <IActionResult> Create([Bind("ID,Name")] Championship championship) { if (ModelState.IsValid) { _context.Add(championship); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(championship)); }
public async Task <IActionResult> Create([Bind("Id,Rank,Player,Team,Position,Age,Gamesplayed,Passescompleted,Fantasypoints,Pprscoring,Posrank,Week1,Week2,Week3,Week4,Week5,Week6,Week7,Week8,Week9,Week10,Week11,Week12,Week13,Week14,Week15,Week16,Week17")] Playersstatistics playersstatistics) { if (ModelState.IsValid) { _context.Add(playersstatistics); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(playersstatistics)); }
public async Task <IActionResult> Create([Bind("DataProvedeniya,Result,CommandID,MatchID")] Match match) { if (ModelState.IsValid) { _context.Add(match); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(match)); }
public async Task <IActionResult> Create(Player player) { if (ModelState.IsValid) { _context.Add(player); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TeamId"] = new SelectList(_context.teams, "TeamId", "TeamId", player.TeamId); return(View(player)); }
public async Task <IActionResult> Create([Bind("PlayerId,FirstName,LastName,ShirtNumber,TeamId")] Player player) { if (ModelState.IsValid) { _context.Add(player); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TeamId"] = new SelectList(_context.Team, "TeamId", "TeamId", player.TeamId); return(View(player)); }
public async Task <IActionResult> Create([Bind("ChampionshipCommandID,ChampionshipID,CommandID")] ChampionshipCommand championshipCommand) { if (ModelState.IsValid) { _context.Add(championshipCommand); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ChampionshipID"] = new SelectList(_context.Championships, "ID", "ID", championshipCommand.ChampionshipID); ViewData["CommandID"] = new SelectList(_context.Commands, "CommandID", "CommandID", championshipCommand.CommandID); return(View(championshipCommand)); }
public async Task <IActionResult> Create([Bind("Id,Name,Sourname,Position,NationalId,ClubId,GoalsNumber,AssistsNumber,DateOfBirth,MatchesNumber")] Footboller footboller) { if (ModelState.IsValid) { _context.Add(footboller); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClubId"] = new SelectList(_context.Clubs, "Id", "Name", footboller.ClubId); ViewData["NationalId"] = new SelectList(_context.Nationals, "Id", "Name", footboller.NationalId); return(View(footboller)); }
public async Task <IActionResult> Create([Bind("PlayerId,SponsorId")] PlayerSponsor playerSponsor) { if (ModelState.IsValid) { _context.Add(playerSponsor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PlayerId"] = new SelectList(_context.Player, "PlayerId", "PlayerId", playerSponsor.PlayerId); ViewData["SponsorId"] = new SelectList(_context.Sponsor, "SponsorId", "SponsorId", playerSponsor.SponsorId); return(View(playerSponsor)); }
public async Task <IActionResult> Create([Bind("Id,Name,PlayersNumber,DateOfBirth,TrophiesNumber,NationalId,PositionInLeague,CupId,LeagueId,EuroCupId")] Club club) { if (ModelState.IsValid) { _context.Add(club); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CupId"] = new SelectList(_context.Cups, "Id", "Name", club.CupId); ViewData["EuroCupId"] = new SelectList(_context.EuroCups, "Id", "Name", club.EuroCupId); ViewData["LeagueId"] = new SelectList(_context.Leagues, "Id", "Name", club.LeagueId); ViewData["NationalId"] = new SelectList(_context.Nationals, "Id", "Name", club.NationalId); return(View(club)); }
public async Task <IActionResult> Create(int nationalCupId, [Bind("Id,Name,TrophiesNumber,NationalCupId")] National national) { national.NationalCupId = nationalCupId; if (ModelState.IsValid) { _context.Add(national); await _context.SaveChangesAsync(); // return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "Nationals", new { id = nationalCupId, name = _context.NationalCups.Where(m => m.Id == nationalCupId).FirstOrDefault().Name })); } ViewData["NationalCupId"] = new SelectList(_context.NationalCups, "Id", "Name", national.NationalCupId); // return View(national); return(RedirectToAction("Index", "Nationals", new { id = nationalCupId, name = _context.NationalCups.Where(m => m.Id == nationalCupId).FirstOrDefault().Name })); }
public async Task ExecuteAsync(AddLeagueCommandArgs args) { var entry = _context.Add(new League { Name = args.Name }); await _context.SaveChangesAsync(); args.Id = entry.Entity.Id; }
public async Task UpdateCompetitionDataAsync(string competitionCode, Competition competition = null) { _logger.LogInformation($"Updating data for league: {competitionCode}"); string[] data = await GetCSVForCompetitionAsync(competitionCode); if (competition is null) { competition = await _context.Competitions.Where(c => c.Code.Equals(competitionCode)).FirstOrDefaultAsync(); } List <Fixture> results = await ParseCompetitionData(data, competition); if (!(results is null)) { _context.Fixtures.AddRange(results); } await _context.SaveChangesAsync(); }
public async Task <IActionResult> Create([Bind("LastName,FirstMidName,SigningDate")] Player player) { try { if (ModelState.IsValid) { _context.Add(player); 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(player)); }
public async Task <IActionResult> Register(string login, string pswd) { if (string.IsNullOrWhiteSpace(login)) { MainModel model = new MainModel() { Password = pswd, ErrorMessage = "Имя пользователя не указано!" }; return(View(model)); } if (string.IsNullOrWhiteSpace(pswd)) { MainModel model = new MainModel() { Login = login, ErrorMessage = "Пароль не корректный!" }; return(View(model)); } UserInfo usr = context.Users.FirstOrDefault(u => u.Username == login); if (usr != null) { MainModel model = new MainModel() { Password = pswd, ErrorMessage = "Данное имя пользователя уже используется" }; return(View(model)); } else { UserInfo user = new UserInfo() { Username = login, PasswordHash = Crypto.HashPassword(pswd), Role = 0, }; await context.Users.AddAsync(user); await context.SaveChangesAsync(); return(Redirect("/Home/Index")); } }
public async Task <int> CommitAsync() { return(await _context.SaveChangesAsync()); }