public ActionResult Create(Round round) { _rounds.InsertOrUpdate(round); _rounds.Save(); return View(round); }
void IRoundRepository.InsertOrUpdate(Round round) { if (round.RoundId == default(int)) { _context.Rounds.Add(round); } else { _context.Entry(round).State = System.Data.EntityState.Modified; } }
public ActionResult Edit(Round round) { if (ModelState.IsValid) { _rounds.InsertOrUpdate(round); _rounds.Save(); } return RedirectToAction("Index", "Round"); }
void IRoundRepository.Remove(Round round) { _context.Entry(round).State = System.Data.EntityState.Deleted; }
public ActionResult CreateRounds(Tournament tournament, int? count) { foreach (var member in tournament.Members) { member.MemberName = _members.All.FirstOrDefault(c => c.MemberId == member.MemberId).MemberName; } tournament.Owner = _users.CurrentUser; _tournaments.InsertOrUpdate(tournament); _tournaments.Save(); for (int i = 0; i < count; i++) { var round = new Round{ Tournament = tournament }; _rounds.InsertOrUpdate(round); _rounds.Save(); //Высчитывается количество столов в раунде, исходя из общего количества участников, учитывая четность/нечетность var tablesCount = tournament.Members.Count() % 2 == 0 ? tournament.Members.Count() / 2 : tournament.Members.Count() / 2 + 1; for (int z = 0; z < tablesCount; z++) { var table = new Table { Round = round }; _tables.InsertOrUpdate(table); _tables.Save(); } } var rounds = _rounds.All; if (tournament != null && _rounds.All.Where(c => c.Tournament.TournamentId == tournament.TournamentId).Any()) { rounds = _rounds.All.Where(c => c.Tournament.TournamentId == tournament.TournamentId); } return PartialView(rounds); }