Exemplo n.º 1
0
        public ActionResult Create(Team team)
        {
            if (ModelState.IsValid)
            {
                db.Teams.Add(team);
                db.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(team);
        }
Exemplo n.º 2
0
        public ActionResult Delete(int? id, Team team)
        {
            team = db.Teams.Single(t => t.TeamID == id);

            if (ModelState.IsValid)
            {
                if (id == null)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }

                if (team == null)
                {
                    return HttpNotFound();
                }

                db.Teams.Remove(team);
                db.SaveChanges();
            }

            return RedirectToAction("Index");
        }
Exemplo n.º 3
0
        public ActionResult Edit(int? id, Team team)
        {           
            team = db.Teams.Single(t => t.TeamID == id);

            if (ModelState.IsValid)
            {
                db.Entry(team).State = EntityState.Modified;
                db.SaveChanges();

                RedirectToAction("Index");
            }
            return View(team);
        }