public async Task <ActionResult> Create([Bind(Include = "ConcedeId,TeamId,GameWeekId,ManagerId,Substitute")] Concede concede) { if (ModelState.IsValid) { concede.Created = DateTime.UtcNow; concede.CreatedBy = User.Identity.Name; var managerGoalKeeper = db.ManagerGoalKeepers.AsNoTracking().Where(x => x.TeamId == concede.TeamId).FirstOrDefault(); if (managerGoalKeeper != null) { concede.ManagerId = managerGoalKeeper.ManagerId; concede.Substitute = managerGoalKeeper.Substitute; } db.Conceded.Add(concede); var team = db.Teams.Where(x => x.TeamId == concede.TeamId).FirstOrDefault(); auditService.Log("Concede", "Concede Added", User.Identity.Name, string.Format("{0} conceded for {1} ({2})", !concede.Cup ? "Goal" : "Cup goal", team?.Name, team?.ManagerGoalKeepers?.FirstOrDefault()?.Manager?.Name ?? "Unattached"), concede.GameWeekId); await db.SaveChangesAsync(); gameWeekSummaryService.Create(concede.GameWeekId); cupWeekSummaryService.Create(concede.GameWeekId); return(RedirectToAction("Index")); } ViewBag.GameWeekId = new SelectList(db.GameWeeks.AsNoTracking().OrderBy(x => x.Number), "GameWeekId", "Details", gameWeekService.GetCurrent()?.GameWeekId); ViewBag.TeamId = new SelectList(db.ManagerGoalKeepers.AsNoTracking().Include(x => x.Team).OrderBy(x => x.Team.Name), "TeamId", "Details"); return(View(concede)); }
public async Task <ActionResult> Create([Bind(Include = "GoalId,PlayerId,GameWeekId")] Goal goal) { if (ModelState.IsValid) { var managerId = db.ManagerPlayers.AsNoTracking().Where(x => x.PlayerId == goal.PlayerId).Select(x => x.ManagerId).FirstOrDefault(); goal.ManagerId = managerId; goal.Created = DateTime.UtcNow; goal.CreatedBy = User.Identity.Name; db.Goals.Add(goal); var player = db.Players.Where(x => x.PlayerId == goal.PlayerId).FirstOrDefault(); auditService.Log("Goal", "Goal Added", User.Identity.Name, string.Format("{0} added for {1} ({2})", !goal.Cup ? "Goal" : "Cup goal", player?.FullName, player?.ManagerPlayers?.FirstOrDefault()?.Manager?.Name ?? "Unattached"), goal.GameWeekId); auditService.Log("Goal", "Goal Added", User.Identity.Name, string.Format("Cup goal added for {0} ({1})", player?.FullName, player?.ManagerPlayers?.FirstOrDefault()?.Manager?.Name ?? "Unattached"), goal.GameWeekId); await db.SaveChangesAsync(); gameWeekSummaryService.Create(goal.GameWeekId); cupWeekSummaryService.Create(goal.GameWeekId); return(RedirectToAction("Index")); } ViewBag.GameWeekId = new SelectList(db.GameWeeks.AsNoTracking().OrderBy(x => x.Number), "GameWeekId", "Details", gameWeekService.GetCurrent()?.GameWeekId); ViewBag.PlayerId = new SelectList(db.ManagerPlayers.AsNoTracking().Include(x => x.Player).Where(x => !x.Substitute).OrderBy(x => x.Player.LastName).ThenBy(x => x.Player.FirstName), "PlayerId", "Details"); return(View(goal)); }
public async Task <ActionResult> Create([Bind(Include = "GameWeekId,Number,Start,Complete")] GameWeek gameWeek) { if (ModelState.IsValid) { db.GameWeeks.Add(gameWeek); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(gameWeek)); }
public async Task <ActionResult> Create([Bind(Include = "MeetingId,Date,Location,Longitude,Latitude")] Meeting meeting) { if (ModelState.IsValid) { db.Meetings.Add(meeting); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(meeting)); }
public async Task <ActionResult> Create([Bind(Include = "HistoryId,Year,Teams,League1,League2,Cup,Plate,LeagueCup")] History history) { if (ModelState.IsValid) { db.History.Add(history); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(history)); }
public async Task <ActionResult> Create([Bind(Include = "CupId,Name,HasGroupStage,KnockoutLegs,FinalLegs")] Cup cup) { if (ModelState.IsValid) { db.Cups.Add(cup); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cup)); }
public async Task <ActionResult> Create([Bind(Include = "LeagueId,Name,Rank")] League league) { if (ModelState.IsValid) { db.Leagues.Add(league); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(league)); }
public async Task <ActionResult> Create([Bind(Include = "TeamId,LeagueId,Name,Alias")] Team team) { if (ModelState.IsValid) { db.Teams.Add(team); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.LeagueId = new SelectList(db.Leagues, "LeagueId", "Name", team.LeagueId); return(View(team)); }
public async Task <ActionResult> Create([Bind(Include = "PlayerId,TeamId,FirstName,LastName,Position")] Player player) { if (ModelState.IsValid) { db.Players.Add(player); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.TeamId = new SelectList(db.Teams.AsNoTracking().OrderBy(x => x.Name), "TeamId", "Name", player.TeamId); return(View(player)); }
public async Task <ActionResult> Create(GroupViewModel groupViewModel) { if (ModelState.IsValid) { foreach (var manager in groupViewModel.Managers.Where(x => x.Selected)) { db.Managers.Attach(manager.Manager); groupViewModel.Group.Managers.Add(manager.Manager); } db.Groups.Add(groupViewModel.Group); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Cup", new { id = groupViewModel.Cup.CupId })); } return(View(groupViewModel)); }
public async Task <ActionResult> Create([Bind(Include = "FixtureId,CupId,GameWeekId,HomeManagerId,AwayManagerId,Round")] Fixture fixture) { if (ModelState.IsValid) { db.Fixtures.Add(fixture); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Cup", new { id = fixture.CupId })); } var managers = db.Managers.AsNoTracking().OrderBy(x => x.Name); ViewBag.AwayManagerId = new SelectList(managers, "ManagerId", "Name", fixture.AwayManagerId); ViewBag.GameWeekId = new SelectList(db.GameWeeks.AsNoTracking().OrderBy(x => x.Number), "GameWeekId", "Details", fixture.GameWeekId); ViewBag.HomeManagerId = new SelectList(managers, "ManagerId", "Name", fixture.HomeManagerId); return(View(fixture)); }
public async Task <ActionResult> Create(ManagerViewModel managerViewModel) { if (ModelState.IsValid) { Manager manager = managerViewModel.Manager; if (!string.IsNullOrEmpty(managerViewModel.Email1.Address)) { manager.AddEmail(managerViewModel.Email1); } if (!string.IsNullOrEmpty(managerViewModel.Email2.Address)) { manager.AddEmail(managerViewModel.Email2); } db.Managers.Add(manager); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(managerViewModel)); }