public IHttpActionResult Players()
        {
            var dc    = new AuctionTrackerContext();
            var teams = dc.Teams.Include(t => t.Players).ToList();

            return(Ok(teams));
        }
Beispiel #2
0
        public void DeletePlayer(Player player)
        {
            var dc = new AuctionTrackerContext();

            dc.Players.Attach(player);
            dc.Entry <Player>(player).State = System.Data.Entity.EntityState.Deleted;
            dc.SaveChanges();
            Clients.All.playerDeleted(player);
        }
Beispiel #3
0
        public void UpdatePlayer(Player player, int originalTeamId)
        {
            var dc = new AuctionTrackerContext();

            dc.Players.Attach(player);
            dc.Entry <Player>(player).State = System.Data.Entity.EntityState.Modified;
            dc.SaveChanges();
            player.TeamName = dc.Teams.Single(t => t.ID == player.TeamID).Name;

            Clients.All.playerUpdated(player, originalTeamId);
        }
Beispiel #4
0
        public void AuctionPlayer(Player player)
        {
            var dc = new AuctionTrackerContext();

            dc.Players.Add(player);
            dc.SaveChanges();
            var team = dc.Teams.Where(t => t.Players.Count() < 16).OrderBy(t => t.LastBid).First();

            team.LastBid = DateTime.Now;
            dc.SaveChanges();

            player.TeamName = team.Name;

            Clients.All.playerAuctioned(player);
        }
Beispiel #5
0
        public IHttpActionResult Get()
        {
            var dc = new AuctionTrackerContext();

            var result = (from p in dc.Players
                          orderby p.ID descending
                          select new
            {
                ID = p.ID,
                NflTeam = p.NflTeam,
                Team = p.Team.Name,
                TeamId = p.TeamID,
                FullName = p.FullName,
                Position = p.Position,
                AuctionAmount = p.AuctionAmount,
            }).Take(3);

            return(Ok(result.ToList()));
        }