public ActionResult ViewMatch(int id) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); Set_TempData(username); var dal = new Competition_services(); var dal2 = new Team_services(); var dal3 = new Player_services(); MatchViewModel model = new MatchViewModel(); model.Match = dal.One_match(id); model.HomePoints = dal.HomePoints(model.Match); model.AwayPoints = dal.AwayPoints(model.Match); if (dal3.Check_existing(model.Match.Match_contestants.ElementAt(0).Contestant.ID) != null) { model.HomeContestant = dal3.Check_existing(model.Match.Match_contestants.ElementAt(0).Contestant.ID).Name; model.AwayContestant = dal3.Check_existing(model.Match.Match_contestants.ElementAt(1).Contestant.ID).Name; } else { model.HomeContestant = dal2.Check_existing(model.Match.Match_contestants.ElementAt(0).Contestant.ID).Name; model.AwayContestant = dal2.Check_existing(model.Match.Match_contestants.ElementAt(1).Contestant.ID).Name; } model.Events = dal.Match_events(model.Match.ID); return(View(model)); }
public ActionResult Players() { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); Set_TempData(username); var dal = new Player_services(); return(View(dal.Player_list())); }
public ActionResult Index(SinglePlayerModel model) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); var dal = new Player_services(); if (model.Comment != null) { dal.Add_comment(model, username); } return(RedirectToAction("Index", new { teamname = model.Player.ID })); }
public ActionResult AddMatch(int id) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); Set_TempData(username); var dal = new Competition_services(); var dal2 = new Team_services(); var dal3 = new Player_services(); SingleMatchModel match = new SingleMatchModel(); match.HomePoints = 0; match.AwayPoints = 0; match.Match = dal.One_match(id); if (dal3.Check_existing(match.Match.Match_contestants.ElementAt(0).Contestant.ID) != null) { match.HomeContestant = dal3.Check_existing(match.Match.Match_contestants.ElementAt(0).Contestant.ID).Name; match.AwayContestant = dal3.Check_existing(match.Match.Match_contestants.ElementAt(1).Contestant.ID).Name; } else { match.HomeContestant = dal2.Check_existing(match.Match.Match_contestants.ElementAt(0).Contestant.ID).Name; match.AwayContestant = dal2.Check_existing(match.Match.Match_contestants.ElementAt(1).Contestant.ID).Name; } List <Event_list> allEvents = dal.Sport_events(match.Match.League.Sport.ID); match.Events = new List <EventModel>(); foreach (var one in allEvents) { EventModel jedan = new EventModel(); jedan.Name = one.Name; jedan.Counts = one.Counts; jedan.Length = one.Length; jedan.Player1 = one.Player1; jedan.Player2 = one.Player2; jedan.Points1 = one.Points1; jedan.Points2 = one.Points2; jedan.Primary = one.Primary; match.Events.Add(jedan); } match.TeamPlayers = new List <string>(); match.TeamPlayers = dal2.TeamPlayers(match.HomeContestant, match.AwayContestant); return(View(match)); }
public ActionResult Index(int id) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); Set_TempData(username); var dal = new Player_services(); SinglePlayerModel model = new SinglePlayerModel { Player = dal.Check_existing(id) }; return(View(model)); }
public ActionResult Index(int id) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); Set_TempData(username); var dal = new Competition_services(); var dal2 = new Team_services(); var dal3 = new Player_services(); CompetitionViewModel model = new CompetitionViewModel(); model.Competition = dal.Check_existing(id); if (model.Competition.Sport.Sport_type.Type_description.Equals("1v1")) { List <Player> svi = new List <Player>(); foreach (var one in model.Competition.Competition_contestants) { svi.Add(dal3.Check_existing(one.Contestant.ID)); } model.Players = svi; } else { List <Team> svi = new List <Team>(); foreach (var one in model.Competition.Competition_contestants) { svi.Add(dal2.Check_existing(one.Contestant.ID)); } model.Teams = svi; } model.Rounds = (model.Competition.Competition_contestants.Count() - 1) * 2; if (!model.Competition.Type_of_competition.DoubleQuadra) { model.Rounds *= 2; } return(View(model)); }
public ActionResult Edit(SinglePlayerModel model) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); var dal = new Player_services(); if (model.Player.Name == null || model.Player.Country == null) { return(RedirectToAction("Edit", new { greska = "Popunite sve podatke o igraču!", id = model.Player.ID })); } MemoryStream target = new MemoryStream(); if (model.Image != null) { model.Image.InputStream.CopyTo(target); model.Player.Picture = target.ToArray(); } dal.Edit_Player(model); return(RedirectToAction("Index", new { id = model.Player.ID })); }
public ActionResult Add(string greska) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); Set_TempData(username); var dal = new Player_services(); var dal2 = new Team_services(); var dal3 = new CompetitionType_services(); BindingList <Type_of_competition> competitionType = dal3.Competition_type_list(); ViewBag.Types = competitionType; BindingList <Sport> sportovi = dal2.Sportovi(); ViewBag.Sportovi = sportovi; TempData["Greska"] = greska; SingleCompetitionModel model = new SingleCompetitionModel(); List <SelectListItem> svi = new List <SelectListItem>(); foreach (var one in dal2.Team_list()) { SelectListItem jedan = new SelectListItem(); jedan.Text = one.Name; svi.Add(jedan); } foreach (var one in dal.Player_list()) { SelectListItem jedan = new SelectListItem(); jedan.Text = one.Name; svi.Add(jedan); } model.Sports = svi; return(View(model)); }
public ActionResult Round(int competition, int kolo) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); var dal = new Competition_services(); var dal2 = new Team_services(); var dal3 = new Player_services(); RoundViewModel model = new RoundViewModel(); Competition current = dal.Check_existing(competition); List <Match> matches = dal.RoundMatches(current, kolo); model.matches = new List <SingleMatchModel>(); foreach (var one in matches) { SingleMatchModel match = new SingleMatchModel(); match.HomePoints = dal.HomePoints(one); match.AwayPoints = dal.AwayPoints(one); match.Match = one; if (current.Sport.Sport_type.Type_name.Equals("1v1")) { match.HomeContestant = dal3.Check_existing(one.Match_contestants.ElementAt(0).Contestant.ID).Name; match.AwayContestant = dal3.Check_existing(one.Match_contestants.ElementAt(1).Contestant.ID).Name; } else { match.HomeContestant = dal2.Check_existing(one.Match_contestants.ElementAt(0).Contestant.ID).Name; match.AwayContestant = dal2.Check_existing(one.Match_contestants.ElementAt(1).Contestant.ID).Name; } model.matches.Add(match); } model.Round = kolo; Set_TempData(username); return(View(model)); }
public ActionResult Add(SinglePlayerModel model) { if (Request.Cookies["user"] == null) { return(RedirectToAction("Login", "User")); } string username = Logged_username(); var dal = new Player_services(); if (model.Player.Name == null || model.Player.Country == null || model.Image == null) { return(RedirectToAction("Add", new { greska = "Popunite sve podatke o igraču!" })); } if (dal.Check_existing(model.Player.Name) != null) { return(RedirectToAction("Add", new { greska = "Igrač već postoji!" })); } MemoryStream target = new MemoryStream(); model.Image.InputStream.CopyTo(target); model.Player.Picture = target.ToArray(); dal.New_Player(model, username); return(RedirectToAction("Index", new { id = dal.Check_existing(model.Player.Name).ID })); }