コード例 #1
0
        public ActionResult Edit(int id, TeamEdit model)
        {
            var service = CreateTeamService();

            ViewBag.LeagueId = new SelectList(service.GetOwnedList("League"), "LeagueId", "LeagueName");
            ViewBag.TeamId   = new SelectList(service.GetOwnedList("Team"), "TeamId", "TeamName");

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.TeamId != id)
            {
                ModelState.AddModelError("", "Ids are mismatched.");
                return(View(model));
            }

            if (service.UpdateTeam(model))
            {
                TempData["SaveResult"] = "Team was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Team could not be updated.");
            return(View(model));
        }
コード例 #2
0
        public ActionResult Edit(int id, TeamEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.TeamId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateTeamService();

            if (service.UpdateTeam(model))
            {
                TempData["SaveResult"] = "Your team was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your team could not be updated.");

            return(View(model));
        }
コード例 #3
0
ファイル: TeamController.cs プロジェクト: abdelilahzaidi/RSE
        // GET: Team/Edit/5
        /*[ProjectManagerRequired]*/
        public ActionResult Edit(int id)
        {
            TeamService r = new TeamService();

            CD.Team  t  = r.Get(id);
            TeamEdit te = new TeamEdit(t);

            return(View(te));
        }
コード例 #4
0
ファイル: TeamController.cs プロジェクト: abdelilahzaidi/RSE
        public ActionResult Edit(int id, TeamEdit collection)
        {
            TeamService r = new TeamService();                                             // Procure les methodes d'acces à la DB

            CD.Team t = new CD.Team(id, collection.Name);                                  // Création d'une nouvelle équipe à partir du formulaire (collection)
            if (r.Update(t))                                                               // r.update(): appel de la methide update pour mettre à jour la team, le if(conntrolle si la mise à jour a été faite)
            {
                return(RedirectToAction("Details", new { controller = "Team", id = id })); // nous redirige vers l'action detail, se trouvant dans le controller Team avec le parametre Id
            }
            return(View(collection));                                                      //retourne le formulaire
        }
コード例 #5
0
        public IHttpActionResult Put(TeamEdit team)
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);

            var service = CreateTeamService();

            if (!service.UpdateTeam(team))
                return InternalServerError();

            return Ok();
        }
コード例 #6
0
 public bool UpdateTeam(TeamEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Teams
             .Single(e => e.TeamId == model.TeamId);
         entity.TeamName = model.TeamName;
         return(ctx.SaveChanges() == 1);
     }
 }
コード例 #7
0
        //public ActionResult TeamDetails(int id)
        //{
        //    var svc = CreateTeamService();
        //    var model = svc.PlayersOnTeam(id);

        //    return View(model);
        //}

        public ActionResult Edit(int id)
        {
            var service = CreateTeamService();
            var detail  = service.GetTeamById(id);
            var model   = new TeamEdit
            {
                TeamId = detail.TeamId,
                Name   = detail.Name
            };

            return(View(model));
        }
コード例 #8
0
        //update team
        public bool PutTeam(TeamEdit newTeamData)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var oldPlayerData =
                    ctx
                    .Teams
                    .Single(p => p.Id == newTeamData.Id);

                oldPlayerData.Id       = newTeamData.Id;
                oldPlayerData.TeamName = newTeamData.TeamName;
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #9
0
        public ActionResult Edit(int id)
        {
            var svc    = CreateTeamService();
            var detail = svc.GetTeamByID(id);
            var model  =
                new TeamEdit
            {
                TeamID      = detail.TeamID,
                Title       = detail.Title,
                Description = detail.Description
            };

            return(View(model));
        }
コード例 #10
0
        public ActionResult Edit(int id)
        {
            var service = CreateTeamService();
            var detail  = service.GetTeamByID(id);
            var model   =
                new TeamEdit
            {
                TeamID    = detail.TeamID,
                TeamName  = detail.TeamName,
                VenueName = detail.VenueName
            };

            return(View(model));
        }
コード例 #11
0
        public bool UpdateTeam(TeamEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Team
                    .Single(e => e.TeamID == model.TeamID && e.UserID == model.UserID);

                entity.TeamName = model.TeamName;
                //entity.Roster = model.Roster;
                //entity.TeamEvents = model.TeamEvents;
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #12
0
        public bool UpdateTeam(TeamEdit team)
        {
            using (var db = new ApplicationDbContext())
            {
                var entity =
                    db
                    .Teams
                    .Single(e => e.TeamID == team.TeamID && e.CoachID == _userID);

                entity.TeamName     = team.TeamName;
                entity.TeamDivision = team.TeamDivision;

                return(db.SaveChanges() == 1);
            }
        }
コード例 #13
0
        //GET: Team/Edit/id
        public ActionResult Edit(int id)
        {
            var svc    = CreateTeamService();
            var detail = svc.GetTeamById(id);
            var model  =
                new TeamEdit
            {
                Id       = detail.Id,
                Name     = detail.Name,
                Familiar = detail.Familiar,
                Assigned = detail.Assigned,
            };

            return(View(model));
        }
コード例 #14
0
        public bool UpdateTeam(TeamEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Teams
                    .Single(e => e.TeamID == model.TeamID && e.OwnerID == _userID);

                entity.Title       = model.Title;
                entity.Description = model.Description;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #15
0
        public bool UpdateTeam(TeamEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Teams
                    .Single(e => e.TeamId == model.TeamId);
                entity.Location   = model.Location;
                entity.Name       = model.Name;
                entity.Conference = ctx.Conferences.Single(c => c.Name == model.Conference);
                entity.TeamId     = model.TeamId;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #16
0
        /// <summary>
        /// This allows you to update a teams name.
        /// </summary>
        /// <param name="team"></param>
        /// <returns></returns>
        public IHttpActionResult Put(TeamEdit team)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var teamService = CreateTeamService();

            if (teamService.UpdateTeam(team))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
コード例 #17
0
 public bool UpdateTeam(TeamEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .TeamDbSet
             .Single(e => e.TeamId == model.Id);
         entity.SquadId  = model.SquadId;
         entity.Squad    = model.Squad;
         entity.Name     = model.Name;
         entity.Familiar = model.Familiar;
         entity.Assigned = model.Assigned;
         return(ctx.SaveChanges() == 1);
     }
 }
コード例 #18
0
        public bool UpdateNote(TeamEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Teams
                    .Single(e => e.TeamID == model.TeamId && e.OwnerID == _userId);

                entity.TeamID           = model.TeamId;
                entity.TeamName         = model.TeamName;
                entity.TeamMembers      = model.TeamMembers;
                entity.NumberPeopleTeam = model.NumberPeopleOnTeam;


                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #19
0
        public bool UpdateExistingTeam(TeamEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Teams.FirstOrDefault(team => team.TeamID == model.TeamID && team.OwnerID == _userID);

                if (entity == null)
                {
                    return(false);
                }

                entity.TeamName  = model.TeamName;
                entity.LeagueID  = model.LeagueID;
                entity.ImageData = model.ImageData;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #20
0
        public bool CheckDependencyAccess(TeamEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var ownedTeam = ctx.Teams.FirstOrDefault(team => team.TeamID == model.TeamID && (team.OwnerID == _userID || team.OwnerID == _publicGuid));

                if (ownedTeam == null)
                {
                    return(false);
                }

                var ownedLeague = ctx.Leagues.FirstOrDefault(league => league.LeagueID == model.LeagueID && (league.OwnerID == _userID || league.OwnerID == _publicGuid));

                if (ownedLeague == null)
                {
                    return(false);
                }

                return(true);
            }
        }
コード例 #21
0
        public ActionResult Edit(int id, TeamEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.Id != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var svc = CreateTeamService();

            if (svc.UpdateTeam(model))
            {
                TempData["SaveResult"] = "Record updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Unable to update record.");
            return(View());
        }
コード例 #22
0
        public IHttpActionResult Put(TeamEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TeamService service = CreateTeamService();

            if (!service.CheckDependencyAccess(model))
            {
                return(BadRequest("Inaccessible dependency"));
            }

            if (service.UpdateExistingTeam(model))
            {
                return(Ok());
            }

            return(InternalServerError());
        }
コード例 #23
0
        public IHttpActionResult Put(int teamId, TeamEdit team)
        {
            if (teamId < 1)
            {
                return(BadRequest("Invalid Team Entry"));
            }
            if (team.TeamId != teamId)
            {
                return(BadRequest("Team Number missmatch"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateTeamService();

            if (!service.UpdateTeam(team))
            {
                return(InternalServerError());
            }
            return(Ok("Team was updated!"));
        }
コード例 #24
0
        public IHttpActionResult PutTeams(int id, TeamEdit team)
        {
            if (id < 1)
            {
                return(BadRequest("Invalid Team Number entry"));
            }
            if (team.Id != id)
            {
                return(BadRequest("Team Number missmatch"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service      = CreateTeamService();
            var isSuccessful = service.PutTeam(team);

            if (!isSuccessful)
            {
                return(InternalServerError());
            }
            return(Ok("Update Successful!"));
        }
コード例 #25
0
        public ActionResult Edit(int id)
        {
            var service = CreateTeamService();
            var detail  = service.GetTeamById(id);
            var model   =
                new TeamEdit
            {
                TeamId   = detail.TeamId,
                TeamName = detail.TeamName,
            };

            var newLeagueList    = new SelectList(service.GetOwnedList("League"), "LeagueId", "LeagueName").ToList();
            var sortedLeagueList = newLeagueList.OrderBy(o => o.Text);

            var newTeamList    = new SelectList(service.GetOwnedList("Team"), "TeamId", "TeamName").ToList();
            var sortedTeamList = newTeamList.OrderBy(o => o.Text);

            ViewBag.LeagueId   = sortedLeagueList;
            ViewBag.TeamId     = sortedTeamList;
            ViewBag.LeagueInfo = detail.LeagueName;

            return(View(model));
        }
コード例 #26
0
        public ActionResult Edit(int id, TeamEdit team)
        {
            if (!ModelState.IsValid)
            {
                return(View(team));
            }

            if (team.TeamID != id)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(team));
            }

            var service = CreateTeamService();

            if (service.UpdateTeam(team))
            {
                TempData["SaveResult"] = "Team was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Team info could not be updated.");
            return(View(team));
        }
コード例 #27
0
 public bool UpdateTeam(TeamEdit model)
 {
     return(ReturnValue);
 }