/// <summary>
 /// Returns all users
 /// </summary>
 /// <returns>List of class User</returns>
 public List<User> GetAllUsers()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetAllUsers();
     }
 }
 /// <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);
     }
 }
 /// <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);
     }
 }
Exemple #4
0
 private static User GetUser(int index)
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetAllUsers()[index];
     }
 }
 /// <summary>
 /// Returns all tickets purchased.
 /// </summary>
 /// <returns>List of class Ticket</returns>
 public List<Ticket> GetAllTickets()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetAllTickets();
     }
 }
Exemple #6
0
 public static void DeleteAllData()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         rep.DeleteAllData();
     }
 }
 /// <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();
     }
 }
 /// <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();
     }
 }
 /// <summary>
 /// Returns the current jackpot balance
 /// </summary>
 /// <returns>Jackpot</returns>
 public Jackpot GetJackpot()
 {
     using (BowlingJackpotRepository rep = new BowlingJackpotRepository())
     {
         return rep.GetJackpotBalance();
     }
 }
 /// <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);
 }
 /// <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);
 }
 /// <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);
 }
 /// <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);
 }
Exemple #14
0
        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 });
            }
        }