コード例 #1
0
 /// <summary>
 /// Returns all users
 /// </summary>
 /// <returns>List of class User</returns>
 public List<User> GetAllUsers()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetAllUsers();
     }
 }
コード例 #2
0
 /// <summary>
 /// Returns a user by ID
 /// </summary>
 /// <param name="id">ID of the User</param>
 /// <returns>User</returns>
 public User GetUserByID(int id)
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetUser(id);
     }
 }
コード例 #3
0
 /// <summary>
 /// Returns ticket by ID
 /// </summary>
 /// <param name="id">ID of the Ticket</param>
 /// <returns>Ticket</returns>
 public Ticket GetTicketByID(int id)
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetTicket(id);
     }
 }
コード例 #4
0
ファイル: Tests.cs プロジェクト: Exploseph/BowlingAPI
 private static User GetUser(int index)
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetAllUsers()[index];
     }
 }
コード例 #5
0
 /// <summary>
 /// Returns all tickets purchased.
 /// </summary>
 /// <returns>List of class Ticket</returns>
 public List<Ticket> GetAllTickets()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetAllTickets();
     }
 }
コード例 #6
0
ファイル: Tests.cs プロジェクト: Exploseph/BowlingAPI
 public static void DeleteAllData()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         rep.DeleteAllData();
     }
 }
コード例 #7
0
 /// <summary>
 /// Picks the weekly bowler to roll for the jackpot. Returns the current weekly play if a bowler is already selected.
 /// </summary>
 /// <returns>WeeklyPlay</returns>          
 public WeeklyPlay PutWeeklyPlay()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.PickWeeklyPlayer();
     }
 }
コード例 #8
0
 /// <summary>
 /// Gets all weekly jackpot plays
 /// </summary>
 /// <returns>List of class WeeklyPlay</returns>        
 public List<WeeklyPlay> GetWeeklyPlays()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetAllWeeklyPlays();
     }
 }
コード例 #9
0
 /// <summary>
 /// Returns the current jackpot balance
 /// </summary>
 /// <returns>Jackpot</returns>
 public Jackpot GetJackpot()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetJackpotBalance();
     }
 }
コード例 #10
0
 /// <summary>
 /// Inserts a user
 /// </summary>
 /// <param name="user">User to insert</param>
 /// <returns>User</returns>
 public HttpResponseMessage PostUser(User user)
 {
     if (ModelState.IsValid)
     {
         using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
         {
             rep.AddUser(user);
         }
         return this.Request.CreateResponse<User>(HttpStatusCode.Created, user);
     }
     else
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
 }
コード例 #11
0
 /// <summary>
 /// Adds a Ticket Amount.  This changes the Ticket Amount for all future Tickets.
 /// </summary>
 /// <param name="ticketAmount">Decimal.  Amount of all tickets going forward</param>
 /// <returns>TicketAmount</returns>
 public HttpResponseMessage PostTicketAmount(TicketAmount ticketAmount)
 {
     if (ModelState.IsValid)
     {
         using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
         {
             rep.AddTicketAmount(ticketAmount);
         }
         return this.Request.CreateResponse<TicketAmount>(HttpStatusCode.Created, ticketAmount);
     }
     else
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
 }
コード例 #12
0
 /// <summary>
 /// Inserts a ticket
 /// </summary>
 /// <param name="ticket">The Ticket to be added</param>
 /// <returns>Ticket</returns>
 public HttpResponseMessage PostTicket(Ticket ticket)
 {
     if (ModelState.IsValid)
     {
         using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
         {
             ticket.TicketAmount = rep.GetCurrentTicketAmount();
             ticket.Purchase_Date = DateTime.UtcNow;
             rep.AddTicket(ticket);
         }
         return this.Request.CreateResponse<Ticket>(HttpStatusCode.Created, ticket);
     }
     else
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
 }
コード例 #13
0
 /// <summary>
 /// Updates a weekly play.
 /// </summary>
 /// <param name="weeklyPlay">WeeklyPlay to be updated</param>
 /// <returns>WeeklyPlay</returns>              
 public HttpResponseMessage PostWeeklyPlay(WeeklyPlay weeklyPlay)
 {
     if (ModelState.IsValid)
     {
         using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
         {
             var result = rep.UpdateWeeklyPlay(weeklyPlay);
             var statusCode = HttpStatusCode.Created;
             if (result == null)
                 statusCode = HttpStatusCode.Forbidden;
             return this.Request.CreateResponse<WeeklyPlay>(statusCode, result);
         }
     }
     else
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
 }
コード例 #14
0
ファイル: Tests.cs プロジェクト: Exploseph/BowlingAPI
        public static void InsertData()
        {
            DeleteAllData();

            using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
            {
                var ticketAmount = rep.GetCurrentTicketAmount();
                foreach (var u in GetUsers())
                {
                    var user = rep.AddUser(u);
                    rep.AddTicket(new Ticket { Purchase_Date = DateTime.UtcNow, Ticket_Amount_Id = ticketAmount.Id, User_Id = user.Id });
                    rep.AddTicket(new Ticket { Purchase_Date = DateTime.UtcNow.AddDays(-7), Ticket_Amount_Id = ticketAmount.Id, User_Id = user.Id });
                    rep.AddTicket(new Ticket { Purchase_Date = DateTime.UtcNow.AddDays(-14), Ticket_Amount_Id = ticketAmount.Id, User_Id = user.Id });
                }

                rep.AddWeeklyPlay(new WeeklyPlay { Play_Date = DateTime.UtcNow.AddDays(-14), User_Id = GetUser(6).Id, Pins = 8, Payout_Amount = 1 });
                rep.AddWeeklyPlay(new WeeklyPlay { Play_Date = DateTime.UtcNow.AddDays(-7), User_Id = GetUser(2).Id, Pins = 8, Payout_Amount = (Decimal)1.9 });
            }
        }