public ActionResult Create([Bind(Include = "TeamId,Name,Image")] Team team) { if (ModelState.IsValid) { db.team.Add(team); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(team)); }
public ActionResult Create([Bind(Include = "StatisticId,Picture")] Statistic statistic) { if (ModelState.IsValid) { db.statistic.Add(statistic); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(statistic)); }
public ActionResult Create([Bind(Include = "CoachId,Name")] Coach coach) { if (ModelState.IsValid) { db.coaches.Add(coach); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CoachId = new SelectList(db.team, "TeamId", "Name", coach.CoachId); return(View(coach)); }
public ActionResult Create([Bind(Include = "ID,Name,LastName,Age,DateOfBirth,Picture,Club,Position,Number,Nationality,TeamId")] Player player) { if (ModelState.IsValid) { db.player.Add(player); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TeamId = new SelectList(db.team, "TeamId", "Name", player.TeamId); return(View(player)); }
public ActionResult Create([Bind(Include = "ID,Ime,Prezime,PrimeniGolovi,Age,DateOfBirth,Played,Club,TeamId")] GoalKeeper goalKeeper) { if (ModelState.IsValid) { db.GoalKeepers.Add(goalKeeper); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TeamId = new SelectList(db.team, "TeamId", "Name", goalKeeper.TeamId); return(View(goalKeeper)); }
public ActionResult Upload(ImageGallery IG) { // Apply Validation Here if (IG.File.ContentLength > (2 * 1024 * 1024)) { ModelState.AddModelError("CustomError", "File size must be less than 2 MB"); return(View()); } if (!(IG.File.ContentType == "image/jpeg" || IG.File.ContentType == "image/gif")) { ModelState.AddModelError("CustomError", "File type allowed : jpeg and gif"); return(View()); } IG.FileName = IG.File.FileName; IG.ImageSize = IG.File.ContentLength; byte[] data = new byte[IG.File.ContentLength]; IG.File.InputStream.Read(data, 0, IG.File.ContentLength); IG.ImageData = data; using (euroContext dc = new euroContext()) { dc.ImageGalleries.Add(IG); dc.SaveChanges(); } return(RedirectToAction("Gallery")); }
public ActionResult Add(MatchDetails matchdetails) { List <SelectListItem> matcheslist = new List <SelectListItem>(); MatchesRepository matchrep = new MatchesRepository(); var mymatches = matchrep.GetAllMatches(); foreach (Match m in mymatches) { if (m.Date == DateTime.Now.Date) { SelectListItem sli = new SelectListItem(); sli.Value = m.MatchId.ToString(); sli.Text = m.HomeTeam.Name + "(" + m.HomeGoals + "-" + m.AwayGoals + ")" + m.GuestTeam.Name; matcheslist.Add(sli); } } db.MatchDetails.Add(matchdetails); db.SaveChanges(); ViewData["Matches"] = matcheslist; return(View()); }
public ActionResult Create([Bind(Include = "MatchDetailsId,Content,MatchId,ID,Name,LastName,StatisticId,HomeTeamId,Min")] MatchDetails matchDetails, int ID) { List <SelectListItem> matcheslist = new List <SelectListItem>(); List <SelectListItem> tlist = new List <SelectListItem>(); MatchesRepository matchrep = new MatchesRepository(); var mymatches = matchrep.GetAllMatches(); if (ModelState.IsValid) { foreach (Match m in mymatches.Where(i => i.HomeTeamId == ID)) { SelectListItem sli1 = new SelectListItem(); SelectListItem sli = new SelectListItem(); sli.Value = m.MatchId.ToString(); sli.Text = m.HomeTeam.Name + " " + m.HomeGoals + "-" + m.AwayGoals + " " + m.GuestTeam.Name; sli1.Value = m.HomeTeamId.ToString(); sli1.Text = m.HomeTeam.Name; matcheslist.Add(sli); tlist.Add(sli1); } ViewData["Matches"] = matcheslist; ViewData["Teams"] = tlist; // ViewData["GuestTeams"] = tlist; db.MatchDetails.Add(matchDetails); db.SaveChanges(); return(RedirectToAction("Index", "Match")); } ViewBag.MatchId = new SelectList(db.matches, "MatchId", "MatchId", matchDetails.MatchId); ViewBag.ID = new SelectList(db.player.Where(i => i.TeamId == ID), "ID", "Name", "LastName", matchDetails.ID); ViewBag.StatisticId = new SelectList(db.statistic, "StatisticId", "PName", matchDetails.StatisticId); ViewBag.HomeTeamId = new SelectList(db.team.Where(i => i.TeamId == ID), "TeamId", "Name", matchDetails.HomeTeamId); // ViewBag.GuestTeamId = new SelectList(db.team.Where(i => i.TeamId == ID), "TeamId", "Name", matchDetails.GuestTeamId); return(View()); }
public ActionResult Add(Match match) { TeamRepository teamrep = new TeamRepository(); List <SelectListItem> teamlist = new List <SelectListItem>(); var myteams = teamrep.GetAllTeams(); if (ModelState.IsValid) { foreach (Team t in myteams) { SelectListItem sli = new SelectListItem(); sli.Value = t.TeamId.ToString(); sli.Text = t.Name; teamlist.Add(sli); } db.matches.Add(match); db.SaveChanges(); ViewData["Teams"] = teamlist; return(RedirectToAction("Index")); } return(View()); }