コード例 #1
0
        //
        // GET: /Team/Edit/5

        public ActionResult Edit(int id = 0)
        {
            Team team = db.Teams.Find(id);
            if (team == null)
            {
                return HttpNotFound();
            }

            EditCreateTeamViewModel model = new EditCreateTeamViewModel(team);
            return View(model);
        }
コード例 #2
0
        public ActionResult Edit(EditCreateTeamViewModel teamModel)
        {
            if (ModelState.IsValid)
            {
                Team team = new Team(teamModel);

                db.Entry(team).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(teamModel);
        }
コード例 #3
0
        public ActionResult Create(EditCreateTeamViewModel teamModel)
        {
            if (ModelState.IsValid)
            {
                Team team = new Team(teamModel);

                db.Teams.Add(team);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(teamModel);
        }
コード例 #4
0
 public Team(EditCreateTeamViewModel teamModel)
 {
     base.Id = teamModel.Id;
     base.Name = teamModel.Name;
     this.DateCreated = DateTime.Now;
 }