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 }); } }
/// <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); }