Ejemplo n.º 1
0
        public ActionResult Edit(int id, PlayerEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            if (model.PlayerId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");

                return(View(model));
            }

            var service = CreatePlayerService();

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

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

            return(View());
        }
Ejemplo n.º 2
0
        public bool UpdatePlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Players
                    .Single(e => e.PlayerId == model.PlayerId && e.OwnerId == _userId);

                entity.FirstName = model.FirstName;
                entity.LastName  = model.LastName;
                entity.Email     = model.Email;
                entity.Handicap  = model.Handicap;
                entity.ShirtSize = model.ShirtSize;
                entity.Dinner    = model.Dinner;
                entity.Raffle    = model.Raffle;
                entity.Mulligans = model.Mulligans;
                entity.Modified  = DateTimeOffset.Now;

                var dinnerEntity =
                    ctx
                    .Dinners
                    .Single(e => e.PlayerId == model.PlayerId);
                dinnerEntity.DinnerChosen = model.Dinner;

                return(ctx.SaveChanges() >= 1);
            }
        }
Ejemplo n.º 3
0
        public bool EditPlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Players.FirstOrDefault(p => p.PlayerId == model.PlayerId);

                entity.PlayerId    = model.PlayerId;
                entity.PlayerName  = model.PlayerName;
                entity.ActiveSince = model.ActiveSince;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int id)
        {
            var service = CreatePlayerService();
            var detail  = service.GetPlayerById(id);
            var model   =
                new PlayerEdit
            {
                PlayerId   = detail.PlayerId,
                PlayerName = detail.PlayerName
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public bool UpdatePlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Users
                    .Single(e => e.Id == model.PlayerId);

                entity.IsStarred = model.IsStarred;

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Put(PlayerEdit player)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreatePlayerService();

            if (!service.UpdatePlayer(player))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Ejemplo n.º 7
0
        public bool PutPlayers(PlayerEdit newPlayerData)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var oldPlayerData =
                    ctx
                    .Players
                    .SingleOrDefault(p => p.PlayerId == newPlayerData.PlayerId);

                oldPlayerData.PlayerId  = newPlayerData.PlayerId;
                oldPlayerData.FirstName = newPlayerData.FirstName;
                oldPlayerData.LastName  = newPlayerData.LastName;
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 8
0
        public ActionResult Edit(int id)
        {
            var service = CreatePlayerService();
            var detail  = service.GetPlayerById(id);
            var model   =
                new PlayerEdit
            {
                PlayerId  = detail.PlayerId,
                FirstName = detail.FirstName,
                LastName  = detail.LastName,
                GroupName = detail.GroupName,
            };

            return(View(model));
        }
Ejemplo n.º 9
0
        public bool UpdatePlayer(PlayerEdit player)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var updatedPlayer =
                    ctx
                    .Players
                    .Single(p => p.Name == player.Name);
                updatedPlayer.Name           = player.Name;
                updatedPlayer.PlayerPosition = player.PlayerPosition;
                updatedPlayer.ModifiedUtc    = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 10
0
        public bool UpdatePlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Players
                    .Single(e => e.PlayerId == model.PlayerId);
                entity.FirstName = model.FirstName;
                entity.LastName  = model.LastName;
                entity.Team.Name = model.TeamName;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 11
0
        public bool UpdatePlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Players
                    .Single(e => e.PlayerId == model.PlayerId && e.OwnerId == _userId);

                entity.PlayerId = model.PlayerId;
                entity.FullName = model.PlayerName;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 12
0
        public bool UpdatePlayer(PlayerEdit player)
        {
            using (var db = new ApplicationDbContext())
            {
                var entity =
                    db
                    .Players
                    .Single(e => e.PlayerID == player.PlayerID && e.CoachID == _userID);

                entity.FullName       = player.FullName;
                entity.PlayerPosition = player.PlayerPosition;
                entity.TeamID         = player.TeamID;

                return(db.SaveChanges() == 1);
            }
        }
        public bool UpdatePlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Players
                    .Single(e => e.PlayerId == model.PlayerId && e.OwnerId == _userId);

                entity.SeasonRebounds    = model.SeasonRebounds;
                entity.SeasonAssists     = model.SeasonAssists;
                entity.SeasonTotalPoints = model.SeasonTotalPoints;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 14
0
        public bool UpdatePlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Players
                    .Single(e => e.PlayerId == model.PlayerId && e.OwnerId == _userId);

                entity.FirstName   = model.FirstName;
                entity.LastName    = model.LastName;
                entity.GroupName   = model.GroupName;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 15
0
        //Admin update player
        public bool UpdatePlayerByAdmin(PlayerEdit model, Guid playerId)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Players
                    .Single(e => e.PlayerId == playerId);


                entity.PlayerPhone   = model.PlayerPhone;
                entity.PlayerAddress = model.PlayerAddress;
                entity.PlayerState   = model.PlayerState;
                entity.PlayerZipCode = model.PlayerZipCode;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 16
0
        public ActionResult Edit(int id)
        {
            ViewBag.TeamId = new SelectList(_db.Teams.ToList(), "TeamId", "Name");

            var service = CreatePlayerService();
            var detail  = service.GetPlayerById(id);
            var model   =
                new PlayerEdit
            {
                PlayerId    = detail.PlayerId,
                FirstName   = detail.FirstName,
                LastName    = detail.LastName,
                ParentEmail = detail.ParentEmail,
                TeamId      = detail.TeamId
            };

            return(View(model));
        }
Ejemplo n.º 17
0
        // GET: Player/Edit/5
        public ActionResult Edit(int id)
        {
            var teams = _db.Teams.ToList().Where(t => t.CoachID == Guid.Parse(User.Identity.GetUserId()));

            ViewBag.TeamID = new SelectList(teams, "TeamID", "TeamName");

            var service = CreatePlayerService();
            var detail  = service.GetPlayerByID(id);
            var model   =
                new PlayerEdit
            {
                PlayerID       = detail.PlayerID,
                FullName       = detail.FullName,
                PlayerPosition = detail.PlayerPosition,
                TeamID         = detail.TeamID
            };

            return(View(model));
        }
Ejemplo n.º 18
0
        private bool SetStarState(string playerId, bool newState)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new LeagueService(userId);

            //Get Player
            var detail = service.GetPlayerById(playerId);

            //Create the PlayerDetail model instance with the new star state
            var updatedPlayer =
                new PlayerEdit
            {
                PlayerId  = detail.Id,
                IsStarred = newState
            };

            //Return a value indicating whether the update succeeded

            return(service.UpdatePlayer(updatedPlayer));
        }
Ejemplo n.º 19
0
        public ActionResult Edit(int id)
        {
            var service = CreatePlayerService();
            var detail  = service.GetPlayerById(id);
            var model   =
                new PlayerEdit
            {
                PlayerId  = detail.PlayerId,
                FirstName = detail.FirstName,
                LastName  = detail.LastName,
                Email     = detail.Email,
                Handicap  = detail.Handicap,
                ShirtSize = detail.ShirtSize,
                Dinner    = detail.Dinner,
                Raffle    = detail.Raffle,
                Mulligans = detail.Mulligans
            };

            return(View(model));
        }
Ejemplo n.º 20
0
        public bool UpdatePlayer(PlayerEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Players
                    .Single(e => e.PlayerId == model.PlayerId);

                entity.Rank        = model.Rank;
                entity.FirstName   = model.FirstName;
                entity.LastName    = model.LastName;
                entity.Position    = model.Position;
                entity.Injured     = model.Injured;
                entity.Drafted     = model.Drafted;
                entity.Note        = model.Note;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult PutPlayers(int playerId, PlayerEdit player)
        {
            if (playerId < 1)
            {
                return(BadRequest("Invalid Player Number entry"));
            }
            if (player.PlayerId != playerId)
            {
                return(BadRequest("Player Number missmatch"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service      = CreatePlayerService();
            var isSuccessful = service.PutPlayers(player);

            if (!isSuccessful)
            {
                return(InternalServerError());
            }
            return(Ok("Update Successful!"));
        }
Ejemplo n.º 22
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            PlayerEdit pe = new PlayerEdit(this, pf);

            pe.Show();
        }
Ejemplo n.º 23
0
 private void PlayerName_Click(object sender, RoutedEventArgs e)
 {
     ToggleVisibility(PlayerEdit, PlayerName);
     PlayerEdit.Focus();
 }