示例#1
0
        public ActionResult Create(Team team)
        {
            if (ModelState.IsValid)
            {
                db.Teams.Add(team);
                db.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(team);
        }
示例#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");
        }
示例#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);
        }