Exemplo n.º 1
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);
 }
 public Ticket AddTicket(Ticket ticket)
 {
     context.Tickets.Add(ticket);
     Save();
     return ticket;
 }