コード例 #1
0
        public ActionResult Create(TeamModel teammodel)
        {
            if (ModelState.IsValid)
            {
                db.Teams.Add(teammodel);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(teammodel);
        }
コード例 #2
0
        // POST api/TeamAPI
        public HttpResponseMessage PostTeamModel(TeamModel teammodel)
        {
            if (ModelState.IsValid)
            {
                db.Teams.Add(teammodel);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, teammodel);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = teammodel.ID }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
コード例 #3
0
        // PUT api/TeamAPI/5
        public HttpResponseMessage PutTeamModel(int id, TeamModel teammodel)
        {
            if (ModelState.IsValid && id == teammodel.ID)
            {
                db.Entry(teammodel).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
コード例 #4
0
 public RoundModel(TeamModel[] teams)
 {
     this.teams = teams;
 }
コード例 #5
0
 public ActionResult Edit(TeamModel teammodel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(teammodel).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(teammodel);
 }
コード例 #6
0
 private List<PlayerModel> GetAllPlayersInTeamById(TeamModel teammodel)
 {
     return (from player in db.PlayerModels
         where player.TeamName == teammodel.TeamName
         select player).ToList();
 }