public ActionResult DeleteConfirmed(int id) { TeamPoints teamPoints = db.TeamPoints.Find(id); db.TeamPoints.Remove(teamPoints); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ID,Name,LogoPath,SelectedTeams,FoudationDate,CountryID,EntityMngID")] Championship championship) { if (championship.LogoPath != null && championship.LogoPath.ContentLength > 0) { string filename = DateTime.Now.Ticks + Path.GetExtension(championship.LogoPath.FileName); var imagePath = Path.Combine(Server.MapPath(Utils.UPLOAD), filename); var imageUrl = Path.Combine(Utils.UPLOAD, filename); championship.LogoPath.SaveAs(imagePath); championship.Logo = String.Concat(Utils.UPLOAD, "/", filename); } if (ModelState.IsValid) { try { db.Championship.Add(championship); db.SaveChanges(); Season season = new Season(); season.ChampshipID = championship.ID; season.NumberOfTeams = 0; season.Year = DateTime.Now; db.Season.Add(season); db.SaveChanges(); foreach (var team in championship.SelectedTeams.Split(',')) { TeamPoints teamPts = new TeamPoints(); teamPts.ChampshipID = championship.ID; teamPts.Points = 0; teamPts.TeamID = int.Parse(team); db.TeamPoints.Add(teamPts); db.SaveChanges(); } return(RedirectToAction("Create", "Journeys", new { area = "", id = championship.ID })); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Diagnostics.Trace.TraceInformation("\n\rProperty: {0}\n\r Error: {1}", validationError.PropertyName, validationError.ErrorMessage); return(RedirectToAction("Create")); } } } } ViewBag.EntityMngID = new SelectList(db.EntityManager, "ID", "Name", championship.EntityMngID); ViewBag.CountryID = new SelectList(db.Country, "ID", "Name", championship.CountryID); return(View(championship)); }
public ActionResult Edit([Bind(Include = "TeamID,ChampshipID,Points")] TeamPoints teamPoints) { if (ModelState.IsValid) { db.Entry(teamPoints).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ChampshipID = new SelectList(db.Championship, "ID", "Name", teamPoints.ChampshipID); ViewBag.TeamID = new SelectList(db.Team, "ID", "Name", teamPoints.TeamID); return(View(teamPoints)); }
// GET: TeamPoints/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TeamPoints teamPoints = db.TeamPoints.Find(id); if (teamPoints == null) { return(HttpNotFound()); } return(View(teamPoints)); }
static void Main() { //1 Console.WriteLine("Sum Of Both Num :"); ReturnSums returnSums = new ReturnSums(); Console.WriteLine("Enter 1st Num:"); int n1 = int.Parse(Console.ReadLine()); Console.WriteLine("Enter 2nd Num:"); int n2 = int.Parse(Console.ReadLine()); bool total = returnSums.Sums(n1, n2); Console.WriteLine($"Your total is {total}."); //2 Console.WriteLine(); Console.WriteLine("Point:"); TeamPoints teamPoints = new TeamPoints(); Console.Write("Enter the number of wins:"); int win = int.Parse(Console.ReadLine()); Console.Write("Enter the number of draws:"); int draw = int.Parse(Console.ReadLine()); Console.Write("Enter the number of loss:"); int loss = int.Parse(Console.ReadLine()); int Point = teamPoints.Points(win, draw, loss); Console.WriteLine($"The points of team is {Point}"); //3 Console.WriteLine(); Console.WriteLine("Read Initials:"); Initials initials = new Initials(); Console.Write("Enter Your Name:"); string input = Console.ReadLine(); string resultInitials = initials.GetInitials(input); Console.WriteLine($"Your Initials is: {resultInitials}"); }
// GET: TeamPoints/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TeamPoints teamPoints = db.TeamPoints.Find(id); if (teamPoints == null) { return(HttpNotFound()); } ViewBag.ChampshipID = new SelectList(db.Championship, "ID", "Name", teamPoints.ChampshipID); ViewBag.TeamID = new SelectList(db.Team, "ID", "Name", teamPoints.TeamID); return(View(teamPoints)); }
private static void AddPointsToTeam(List <TeamPoints> allTeamsPoints, int teamId, int pointsToAdd) { var team = allTeamsPoints.FirstOrDefault(x => x.TeamId == teamId); if (team != null) { team.TeamPointsValue = team.TeamPointsValue + pointsToAdd; } else { using (var db = new sakilaEntities4()) { var team2 = db.team.First(x => x.TeamID == teamId); var newTeam = new TeamPoints(); newTeam.TeamName = team2.TeamName; newTeam.TeamId = team2.TeamID; newTeam.TeamPointsValue = pointsToAdd; allTeamsPoints.Add(newTeam); } } }